2015-12-06 21:11:41 +00:00
|
|
|
auto SMP::tick() -> void {
|
2011-05-05 11:40:22 +00:00
|
|
|
timer0.tick();
|
|
|
|
timer1.tick();
|
|
|
|
timer2.tick();
|
2011-05-05 11:37:46 +00:00
|
|
|
|
|
|
|
clock += cycle_step_cpu;
|
|
|
|
dsp.clock -= 24;
|
2015-12-06 21:11:41 +00:00
|
|
|
synchronizeDSP();
|
2011-05-05 11:37:46 +00:00
|
|
|
}
|
|
|
|
|
2015-12-06 21:11:41 +00:00
|
|
|
auto SMP::op_io() -> void {
|
2011-05-05 11:37:46 +00:00
|
|
|
#if defined(CYCLE_ACCURATE)
|
|
|
|
tick();
|
|
|
|
#endif
|
2011-05-02 13:53:16 +00:00
|
|
|
}
|
|
|
|
|
2015-12-06 21:11:41 +00:00
|
|
|
auto SMP::op_read(uint16 addr) -> uint8 {
|
2011-05-05 11:37:46 +00:00
|
|
|
#if defined(CYCLE_ACCURATE)
|
|
|
|
tick();
|
|
|
|
#endif
|
2011-05-02 13:53:16 +00:00
|
|
|
if((addr & 0xfff0) == 0x00f0) return mmio_read(addr);
|
2011-05-05 11:40:22 +00:00
|
|
|
if(addr >= 0xffc0 && status.iplrom_enable) return iplrom[addr & 0x3f];
|
2011-05-02 13:53:16 +00:00
|
|
|
return apuram[addr];
|
|
|
|
}
|
|
|
|
|
2015-12-06 21:11:41 +00:00
|
|
|
auto SMP::op_write(uint16 addr, uint8 data) -> void {
|
2011-05-05 11:37:46 +00:00
|
|
|
#if defined(CYCLE_ACCURATE)
|
|
|
|
tick();
|
|
|
|
#endif
|
2011-05-02 13:53:16 +00:00
|
|
|
if((addr & 0xfff0) == 0x00f0) mmio_write(addr, data);
|
|
|
|
apuram[addr] = data; //all writes go to RAM, even MMIO writes
|
|
|
|
}
|
|
|
|
|
2015-12-06 21:11:41 +00:00
|
|
|
auto SMP::op_step() -> void {
|
Update to v078r02 release.
byuu says:
New S-SMP core is feature-complete, but still buggy. It's good enough
for perfect audio in Zelda 3 and Super Mario World, but there are plenty
of issues. No audio in Bahamut Lagoon, deadlock in Earthworm Jim 2,
etc.
With this core, bsnes/Performance runs about 3-5% faster than with the
old one. That won't seem like much, because the S-SMP is the least
demanding portion of the SNES. blargg's SMP core netted me a 5-8%
speedup the last time I tried it, so I'm sure there's still room to
speed things up.
The core is opcode-based, but has dummy op_io() calls (they compile to
nothing), so it is trivial to make it cycle-based if desired. I'm not
convinced that is necessary, but we shall see once we get the opcode
bugs ironed out.
2011-05-03 09:58:12 +00:00
|
|
|
#define op_readpc() op_read(regs.pc++)
|
|
|
|
#define op_readdp(addr) op_read((regs.p.p << 8) + addr)
|
|
|
|
#define op_writedp(addr, data) op_write((regs.p.p << 8) + addr, data)
|
2011-05-05 11:37:46 +00:00
|
|
|
#define op_readaddr(addr) op_read(addr)
|
|
|
|
#define op_writeaddr(addr, data) op_write(addr, data)
|
|
|
|
#define op_readstack() op_read(0x0100 | ++regs.sp)
|
|
|
|
#define op_writestack(data) op_write(0x0100 | regs.sp--, data)
|
2011-05-02 13:53:16 +00:00
|
|
|
|
2011-05-05 11:37:46 +00:00
|
|
|
#if defined(CYCLE_ACCURATE)
|
|
|
|
|
|
|
|
if(opcode_cycle == 0) {
|
|
|
|
opcode_number = op_readpc();
|
|
|
|
opcode_cycle++;
|
|
|
|
} else switch(opcode_number) {
|
2013-05-05 09:21:30 +00:00
|
|
|
#include "core/opcycle_misc.cpp"
|
|
|
|
#include "core/opcycle_mov.cpp"
|
|
|
|
#include "core/opcycle_pc.cpp"
|
|
|
|
#include "core/opcycle_read.cpp"
|
|
|
|
#include "core/opcycle_rmw.cpp"
|
2011-05-05 11:37:46 +00:00
|
|
|
}
|
Update to v078r02 release.
byuu says:
New S-SMP core is feature-complete, but still buggy. It's good enough
for perfect audio in Zelda 3 and Super Mario World, but there are plenty
of issues. No audio in Bahamut Lagoon, deadlock in Earthworm Jim 2,
etc.
With this core, bsnes/Performance runs about 3-5% faster than with the
old one. That won't seem like much, because the S-SMP is the least
demanding portion of the SNES. blargg's SMP core netted me a 5-8%
speedup the last time I tried it, so I'm sure there's still room to
speed things up.
The core is opcode-based, but has dummy op_io() calls (they compile to
nothing), so it is trivial to make it cycle-based if desired. I'm not
convinced that is necessary, but we shall see once we get the opcode
bugs ironed out.
2011-05-03 09:58:12 +00:00
|
|
|
|
2011-05-05 11:37:46 +00:00
|
|
|
#else
|
Update to v078r02 release.
byuu says:
New S-SMP core is feature-complete, but still buggy. It's good enough
for perfect audio in Zelda 3 and Super Mario World, but there are plenty
of issues. No audio in Bahamut Lagoon, deadlock in Earthworm Jim 2,
etc.
With this core, bsnes/Performance runs about 3-5% faster than with the
old one. That won't seem like much, because the S-SMP is the least
demanding portion of the SNES. blargg's SMP core netted me a 5-8%
speedup the last time I tried it, so I'm sure there's still room to
speed things up.
The core is opcode-based, but has dummy op_io() calls (they compile to
nothing), so it is trivial to make it cycle-based if desired. I'm not
convinced that is necessary, but we shall see once we get the opcode
bugs ironed out.
2011-05-03 09:58:12 +00:00
|
|
|
|
2015-12-06 21:11:41 +00:00
|
|
|
uint opcode = op_readpc();
|
2011-05-05 11:37:46 +00:00
|
|
|
switch(opcode) {
|
2013-05-05 09:21:30 +00:00
|
|
|
#include "core/op_misc.cpp"
|
|
|
|
#include "core/op_mov.cpp"
|
|
|
|
#include "core/op_pc.cpp"
|
|
|
|
#include "core/op_read.cpp"
|
|
|
|
#include "core/op_rmw.cpp"
|
2011-05-02 13:53:16 +00:00
|
|
|
}
|
|
|
|
|
2011-05-05 11:40:22 +00:00
|
|
|
//TODO: untaken branches should consume less cycles
|
|
|
|
|
Update to v078r02 release.
byuu says:
New S-SMP core is feature-complete, but still buggy. It's good enough
for perfect audio in Zelda 3 and Super Mario World, but there are plenty
of issues. No audio in Bahamut Lagoon, deadlock in Earthworm Jim 2,
etc.
With this core, bsnes/Performance runs about 3-5% faster than with the
old one. That won't seem like much, because the S-SMP is the least
demanding portion of the SNES. blargg's SMP core netted me a 5-8%
speedup the last time I tried it, so I'm sure there's still room to
speed things up.
The core is opcode-based, but has dummy op_io() calls (they compile to
nothing), so it is trivial to make it cycle-based if desired. I'm not
convinced that is necessary, but we shall see once we get the opcode
bugs ironed out.
2011-05-03 09:58:12 +00:00
|
|
|
timer0.tick(cycle_count_table[opcode]);
|
|
|
|
timer1.tick(cycle_count_table[opcode]);
|
|
|
|
timer2.tick(cycle_count_table[opcode]);
|
|
|
|
|
|
|
|
clock += cycle_table_cpu[opcode];
|
|
|
|
dsp.clock -= cycle_table_dsp[opcode];
|
|
|
|
synchronize_dsp();
|
2011-05-05 11:37:46 +00:00
|
|
|
|
|
|
|
#endif
|
2011-05-02 13:53:16 +00:00
|
|
|
}
|
|
|
|
|
2015-12-06 21:11:41 +00:00
|
|
|
const uint SMP::cycle_count_table[256] = {
|
2011-05-02 13:53:16 +00:00
|
|
|
#define c 12
|
|
|
|
//0 1 2 3 4 5 6 7 8 9 A B C D E F
|
|
|
|
2,8,4,7, 3,4,3,6, 2,6,5,4, 5,4,6,8, //0
|
|
|
|
4,8,4,7, 4,5,5,6, 5,5,6,5, 2,2,4,6, //1
|
|
|
|
2,8,4,7, 3,4,3,6, 2,6,5,4, 5,4,7,4, //2
|
|
|
|
4,8,4,7, 4,5,5,6, 5,5,6,5, 2,2,3,8, //3
|
|
|
|
|
|
|
|
2,8,4,7, 3,4,3,6, 2,6,4,4, 5,4,6,6, //4
|
|
|
|
4,8,4,7, 4,5,5,6, 5,5,4,5, 2,2,4,3, //5
|
|
|
|
2,8,4,7, 3,4,3,6, 2,6,4,4, 5,4,7,5, //6
|
|
|
|
4,8,4,7, 4,5,5,6, 5,5,5,5, 2,2,3,6, //7
|
|
|
|
|
|
|
|
2,8,4,7, 3,4,3,6, 2,6,5,4, 5,2,4,5, //8
|
|
|
|
4,8,4,7, 4,5,5,6, 5,5,5,5, 2,2,c,5, //9
|
|
|
|
3,8,4,7, 3,4,3,6, 2,6,4,4, 5,2,4,4, //A
|
|
|
|
4,8,4,7, 4,5,5,6, 5,5,5,5, 2,2,3,4, //B
|
|
|
|
|
|
|
|
3,8,4,7, 4,5,4,7, 2,5,6,4, 5,2,4,9, //C
|
|
|
|
4,8,4,7, 5,6,6,7, 4,5,5,5, 2,2,8,3, //D
|
|
|
|
2,8,4,7, 3,4,3,6, 2,4,5,3, 4,3,4,1, //E
|
|
|
|
4,8,4,7, 4,5,5,6, 3,4,5,4, 2,2,6,1, //F
|
|
|
|
|
|
|
|
#undef c
|
|
|
|
};
|