2015-07-01 10:58:42 +00:00
|
|
|
BIOS::BIOS() {
|
|
|
|
size = 16384;
|
|
|
|
data = new uint8[size]();
|
|
|
|
}
|
|
|
|
|
|
|
|
BIOS::~BIOS() {
|
|
|
|
delete[] data;
|
|
|
|
}
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto BIOS::read(uint mode, uint32 addr) -> uint32 {
|
2015-09-28 11:56:46 +00:00
|
|
|
//unmapped memory
|
|
|
|
if(addr >= 0x0000'4000) return cpu.pipeline.fetch.instruction; //0000'4000-01ff'ffff
|
|
|
|
|
2012-04-14 07:26:45 +00:00
|
|
|
//GBA BIOS is read-protected; only the BIOS itself can read its own memory
|
2015-09-28 11:56:46 +00:00
|
|
|
//when accessed elsewhere; this should return the last value read by the BIOS program
|
|
|
|
if(cpu.r(15) >= 0x0000'4000) return mdr;
|
2012-04-14 07:26:45 +00:00
|
|
|
|
2015-07-01 10:58:42 +00:00
|
|
|
if(mode & Word) return mdr = read(Half, addr &~ 2) << 0 | read(Half, addr | 2) << 16;
|
|
|
|
if(mode & Half) return mdr = read(Byte, addr &~ 1) << 0 | read(Byte, addr | 1) << 8;
|
2012-04-14 07:26:45 +00:00
|
|
|
|
2015-09-28 11:56:46 +00:00
|
|
|
return mdr = data[addr];
|
2012-04-14 07:26:45 +00:00
|
|
|
}
|
|
|
|
|
2015-11-16 08:38:05 +00:00
|
|
|
auto BIOS::write(uint mode, uint32 addr, uint32 word) -> void {
|
2012-04-14 07:26:45 +00:00
|
|
|
}
|