mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-07-28 00:29:09 +00:00
Correct some rom initialisation/loading issues.
This commit is contained in:
parent
129286f1a7
commit
c5c842a70b
@ -2,7 +2,15 @@
|
|||||||
#include "GameBoyBus.h"
|
#include "GameBoyBus.h"
|
||||||
|
|
||||||
EightBit::GameBoy::Bus::Bus()
|
EightBit::GameBoy::Bus::Bus()
|
||||||
: m_disableBootRom(false),
|
: m_bootRom(0x100),
|
||||||
|
m_gameRomBanks(1),
|
||||||
|
m_videoRam(0x2000),
|
||||||
|
m_ramBanks(0),
|
||||||
|
m_lowInternalRam(0x2000),
|
||||||
|
m_oamRam(0xa0),
|
||||||
|
m_ioPorts(0x80),
|
||||||
|
m_highInternalRam(0x80),
|
||||||
|
m_disableBootRom(false),
|
||||||
m_disableGameRom(false),
|
m_disableGameRom(false),
|
||||||
m_rom(false),
|
m_rom(false),
|
||||||
m_banked(false),
|
m_banked(false),
|
||||||
@ -32,13 +40,11 @@ void EightBit::GameBoy::Bus::loadBootRom(const std::string& path) {
|
|||||||
void EightBit::GameBoy::Bus::loadGameRom(const std::string& path) {
|
void EightBit::GameBoy::Bus::loadGameRom(const std::string& path) {
|
||||||
const auto bankSize = 0x4000;
|
const auto bankSize = 0x4000;
|
||||||
m_gameRomBanks.resize(1);
|
m_gameRomBanks.resize(1);
|
||||||
const auto size = m_gameRomBanks[0].load(path, bankSize);
|
const auto size = m_gameRomBanks[0].load(path, 0, 0, bankSize);
|
||||||
auto banks = size / bankSize;
|
const auto banks = size / bankSize;
|
||||||
if (banks > 1) {
|
m_gameRomBanks.resize(banks);
|
||||||
m_gameRomBanks.resize(banks);
|
for (int bank = 1; bank < banks; ++bank)
|
||||||
for (int bank = 1; bank < banks; ++banks)
|
m_gameRomBanks[bank].load(path, 0, bankSize * bank, bankSize);
|
||||||
m_gameRomBanks[bank].load(path, bankSize, bankSize * bank);
|
|
||||||
}
|
|
||||||
validateCartridgeType();
|
validateCartridgeType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,15 +20,15 @@ int EightBit::Memory::loadBinary(
|
|||||||
if ((maximumSize > 0) && ((size - readOffset) > maximumSize))
|
if ((maximumSize > 0) && ((size - readOffset) > maximumSize))
|
||||||
throw std::runtime_error("Binary cannot fit");
|
throw std::runtime_error("Binary cannot fit");
|
||||||
|
|
||||||
size_t extent = size + writeOffset;
|
|
||||||
if (output.size() < extent)
|
|
||||||
output.resize(extent);
|
|
||||||
|
|
||||||
file.seekg(readOffset, std::ios::beg);
|
file.seekg(readOffset, std::ios::beg);
|
||||||
|
|
||||||
if ((limit < 0) || (limit > size))
|
if ((limit < 0) || (limit > size))
|
||||||
limit = size;
|
limit = size;
|
||||||
|
|
||||||
|
const size_t extent = limit + writeOffset;
|
||||||
|
if (output.size() < extent)
|
||||||
|
output.resize(extent);
|
||||||
|
|
||||||
file.read((char*)&output[writeOffset], limit);
|
file.read((char*)&output[writeOffset], limit);
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user