Update rom and sram init
This commit is contained in:
@@ -23,19 +23,16 @@ void MemoryImpl::Initialize(const std::vector<uint8_t>& romData, bool verbose) {
|
||||
rom_.resize(romSize);
|
||||
|
||||
// Copy memory into rom_
|
||||
std::copy(romData.begin() + kROMStart, romData.begin() + kROMStart + kROMSize,
|
||||
rom_.begin());
|
||||
|
||||
memory_.resize(0x1000000); // 16 MB
|
||||
|
||||
const size_t ROM_CHUNK_SIZE = 0x8000; // 32 KB
|
||||
std::copy(romData.begin(), romData.begin() + romSize, rom_.begin());
|
||||
|
||||
// Clear memory
|
||||
memory_.resize(0x1000000); // 16 MB
|
||||
std::fill(memory_.begin(), memory_.end(), 0);
|
||||
|
||||
// Load ROM data into memory based on LoROM mapping
|
||||
size_t romSize = romData.size();
|
||||
size_t romAddress = 0;
|
||||
const size_t ROM_CHUNK_SIZE = 0x8000; // 32 KB
|
||||
for (size_t bank = 0x00; bank <= 0x3F; ++bank) {
|
||||
for (size_t offset = 0x8000; offset <= 0xFFFF; offset += ROM_CHUNK_SIZE) {
|
||||
if (romAddress < romSize) {
|
||||
@@ -46,16 +43,6 @@ void MemoryImpl::Initialize(const std::vector<uint8_t>& romData, bool verbose) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copy data into rom_ vector
|
||||
rom_.resize(kROMSize);
|
||||
std::copy(memory_.begin() + kROMStart, memory_.begin() + kROMStart + kROMSize,
|
||||
rom_.begin());
|
||||
|
||||
// Copy data into ram_ vector
|
||||
ram_.resize(kRAMSize);
|
||||
std::copy(memory_.begin() + kRAMStart, memory_.begin() + kRAMStart + kRAMSize,
|
||||
ram_.begin());
|
||||
}
|
||||
|
||||
memory::RomInfo MemoryImpl::ReadRomHeader() {
|
||||
|
||||
@@ -22,19 +22,6 @@ namespace app {
|
||||
namespace emu {
|
||||
|
||||
void SNES::Init(Rom& rom) {
|
||||
// Load the ROM into memory and set up the memory mapping
|
||||
rom_data = rom.vector();
|
||||
memory_.Initialize(rom_data);
|
||||
|
||||
// Read the ROM header
|
||||
rom_info_ = memory_.ReadRomHeader();
|
||||
Reset();
|
||||
|
||||
// Disable the emulation flag (switch to 65816 native mode)
|
||||
cpu_.E = 0;
|
||||
cpu_.PB = 0x00;
|
||||
cpu_.PC = 0x8000;
|
||||
|
||||
// Initialize CPU
|
||||
cpu_.Init();
|
||||
|
||||
@@ -44,6 +31,19 @@ void SNES::Init(Rom& rom) {
|
||||
// Initialize APU
|
||||
apu_.Init();
|
||||
|
||||
// Load the ROM into memory and set up the memory mapping
|
||||
rom_data = rom.vector();
|
||||
memory_.Initialize(rom_data);
|
||||
|
||||
// Read the ROM header
|
||||
// rom_info_ = memory_.ReadRomHeader();
|
||||
Reset(true);
|
||||
|
||||
// Disable the emulation flag (switch to 65816 native mode)
|
||||
cpu_.E = 0;
|
||||
// cpu_.PB = 0x00;
|
||||
// cpu_.PC = 0x8000;
|
||||
|
||||
// Disable interrupts and rendering
|
||||
memory_.WriteByte(0x4200, 0x00); // NMITIMEN
|
||||
memory_.WriteByte(0x420C, 0x00); // HDMAEN
|
||||
@@ -90,7 +90,7 @@ void SNES::Reset(bool hard) {
|
||||
input1.latchedState = 0;
|
||||
input2.latchedState = 0;
|
||||
// cart_reset();
|
||||
// if(hard) memset(ram, 0, sizeof(ram));
|
||||
if (hard) memset(ram, 0, sizeof(ram));
|
||||
ram_adr_ = 0;
|
||||
memory_.set_h_pos(0);
|
||||
memory_.set_v_pos(0);
|
||||
|
||||
Reference in New Issue
Block a user