Skip to content

Commit

Permalink
fixed something with the rom saving, metroid doesnt work though
Browse files Browse the repository at this point in the history
  • Loading branch information
Roeegg2 committed Mar 19, 2024
1 parent 49b5c9a commit 3d3f332
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ uint16_t emulator_tick(Bus* bus) {
}

int main() {
const std::string rom_path = "roms/SMB2.nes";
const std::string rom_path = "roms/METROID.nes";
const std::string palette_path = "ntscpalette.pal";

Controller* const controller_1 = new Controller();
Expand Down
4 changes: 2 additions & 2 deletions src/mapper_n_cart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ namespace roee_nes {
}

uint8_t Save_RAM::mapper_read(const uint16_t addr) {
return save_data[addr % 0x6000];
return save_data[addr % 0x2000];
}

void Save_RAM::mapper_write(const uint16_t addr, const uint8_t data) {
save_data[addr % 0x6000] = data;
save_data[addr % 0x2000] = data;
}


Expand Down
5 changes: 4 additions & 1 deletion src/mappers/mmc1_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ namespace roee_nes {

if (cart->header.flag_6.parsed.prg_ram == 1)
save_ram = new Save_RAM(cart->rom_path + ".sav");
else
save_ram = nullptr;
}

void MMC1_1::cpu_write(uint16_t addr, uint8_t data) {
Expand Down Expand Up @@ -152,6 +154,7 @@ namespace roee_nes {
}

void MMC1_1::save() {
save_ram->~Save_RAM();
if (save_ram != nullptr)
save_ram->~Save_RAM();
}
}
9 changes: 7 additions & 2 deletions src/mappers/mmc3_4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ namespace roee_nes {
chr_bank_num = (chr_read_mem->size() / (1 * KILOBYTE)) - 2;
prg_bank_num = (cart->prg_rom.size() / (8 * KILOBYTE));

save_ram = new Save_RAM(cart->rom_path + ".sav");
if (cart->header.flag_6.parsed.prg_ram == 1)
save_ram = new Save_RAM(cart->rom_path + ".sav");
else
save_ram = nullptr;

prg_bank[0] = 0;
prg_bank[1] = 0;
chr_bank[0] = 0;
Expand Down Expand Up @@ -211,6 +215,7 @@ namespace roee_nes {
}

void MMC3_4::save() {
save_ram->~Save_RAM();
if (save_ram != nullptr)
save_ram->~Save_RAM();
}
}

0 comments on commit 3d3f332

Please sign in to comment.