Skip to content

Commit

Permalink
ng: beginnings of neo geo cd emulation
Browse files Browse the repository at this point in the history
This is just a basic skeleton that implements enough to boot the bios.

There is no CD-ROM support yet; games cannot boot.
  • Loading branch information
LukeUsher committed Feb 6, 2025
1 parent 1323a62 commit 0102da6
Show file tree
Hide file tree
Showing 20 changed files with 425 additions and 51 deletions.
11 changes: 10 additions & 1 deletion ares/ng/apu/apu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ APU apu;

auto APU::load(Node::Object parent) -> void {
node = parent->append<Node::Object>("APU");
ram.allocate(2_KiB);
ram.allocate(Model::NeoGeoCD() ? 64_KiB : 2_KiB);
debugger.load(node);
}

Expand Down Expand Up @@ -50,4 +50,13 @@ auto APU::power(bool reset) -> void {
rom = {};
}

auto APU::restart() -> void {
Z80::reset();
Thread::restart({&APU::main, this});
communication = {};
nmi = {};
irq = {};
rom = {};
}

}
1 change: 1 addition & 0 deletions ares/ng/apu/apu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct APU : Z80, Z80::Bus, Thread {
auto main() -> void;
auto step(u32 clocks) -> void override;
auto power(bool reset) -> void;
auto restart() -> void;

//memory.cpp
auto read(n16 address) -> n8 override;
Expand Down
6 changes: 6 additions & 0 deletions ares/ng/apu/memory.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
auto APU::read(n16 address) -> n8 {
if(Model::NeoGeoCD()) return ram[address];
if(address <= 0x7fff) return cartridge.readM(address);
if(address <= 0xbfff) return cartridge.readM(rom.bankA << 14 | n14(address));
if(address <= 0xdfff) return cartridge.readM(rom.bankB << 13 | n13(address));
Expand All @@ -9,6 +10,11 @@ auto APU::read(n16 address) -> n8 {
}

auto APU::write(n16 address, n8 data) -> void {
if(Model::NeoGeoCD()) {
ram[address] = data;
return;
}

if(address >= 0xf800) {
ram[address & 0x7ff] = data;
return;
Expand Down
2 changes: 2 additions & 0 deletions ares/ng/cpu/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ auto CPU::main() -> void {

if(2 > r.i && lower(Interrupt::Timer)) {
debugger.interrupt("Timer");
if(Model::NeoGeoCD()) return interrupt(Vector::Level1, 1);
return interrupt(Vector::Level2, 2);
}

if(1 > r.i && lower(Interrupt::Vblank)) {
debugger.interrupt("Vblank");
if(Model::NeoGeoCD()) return interrupt(Vector::Level2, 2);
return interrupt(Vector::Level1, 1);
}
}
Expand Down
Loading

0 comments on commit 0102da6

Please sign in to comment.