Update to v103r07 release.
byuu says:
Changelog:
- gba/cpu: massive code cleanup effort
- gba/cpu: DMA can run in between active instructions¹
- gba/cpu: added two-cycle startup delay between DMA activation and
DMA transfers²
- processor/spc700: BBC, BBC, CBNE cycle 4 is an idle cycle
- processor/spc700: ADDW, SUBW, MOVW (read) cycle 4 is an idle cycle
¹: unfortunately, this causes yet another performance penalty for the
poor GBA core =( Also, I think I may have missed disabling DMAs while
the CPU is stopped. I'll fix that in the next WIP.
²: I put the waiting counter decrement at the wrong place, so this
doesn't actually work. Needs to be more like
this:
auto CPU::step(uint clocks) -> void {
for(auto _ : range(clocks)) {
for(auto& timer : this->timer) timer.run();
for(auto& dma : this->dma) if(dma.active && dma.waiting) dma.waiting--;
context.clock++;
}
...
auto CPU::DMA::run() -> bool {
if(cpu.stopped() || !active || waiting) return false;
transfer();
if(irq) cpu.irq.flag |= CPU::Interrupt::DMA0 << id;
if(drq && id == 3) cpu.irq.flag |= CPU::Interrupt::Cartridge;
return true;
}
Of course, the real fix will be restructuring how DMA works, so that
it's always running in parallel with the CPU instead of this weird
design where it tries to run all channels in some kind of loop until no
channels are active anymore whenever one channel is activated.
Not really sure how to design that yet, however.
2017-07-05 05:29:27 +00:00
|
|
|
BIOS bios;
|
|
|
|
|
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
|
2017-08-09 11:11:59 +00:00
|
|
|
if(cpu.processor.r15 >= 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
|
|
|
}
|