bsnes/sfc/smp/timing.cpp
Tim Allen 6d9f43a37b Update to v095r05 release.
byuu says:

Changelog:
- GBA: lots of emulation improvements
- PPU PRAM is 16-bits wide
- DMA masks &~1/Half, &~3/Word
- VRAM OBJ 8-bit writes are ignored
- OAM 8-bit writes are ignored
- BGnCNT unused bits are writable*
- BG(0,1)CNT can't set the d13
- BLDALPHA is readable (fixes Donkey Kong Country, etc)
- SNES: lots of code cleanups
- sfc/chip => sfc/coprocessor
- UI: save most recent controller selection

GBA test scores: 1552/1552, 37/38, 1020/1260

(* forgot to add the value to the read function, so endrift's I/O tests
for them will fail. Fixed locally.)

Note: SNES is the only system with multiple controller/expansion port
options, and as such is the only one with a "None" option. Because it's
shared by the controller and expansion port, it ends up sorted first in
the list. This means that on your first run, you'll need to go to Super
Famicom->Controller Port 1 and select "Gamepad", otherwise input won't
work.

Also note that changing the expansion port device requires loading a new
cart. Unlike controllers, you aren't meant to hotplug expansion port
devices.
2015-11-12 21:15:03 +11:00

59 lines
1.5 KiB
C++

auto SMP::addClocks(uint clocks) -> void {
step(clocks);
synchronizeDSP();
#if defined(DEBUGGER)
synchronizeCPU();
#else
//forcefully sync S-SMP to S-CPU in case chips are not communicating
//sync if S-SMP is more than 24 samples ahead of S-CPU
if(clock > +(768 * 24 * (int64)24000000)) synchronizeCPU();
#endif
}
auto SMP::cycleEdge() -> void {
timer0.tick();
timer1.tick();
timer2.tick();
//TEST register S-SMP speed control
//24 clocks have already been added for this cycle at this point
switch(status.clockSpeed) {
case 0: break; //100% speed
case 1: addClocks(24); break; // 50% speed
case 2: while(true) addClocks(24); // 0% speed -- locks S-SMP
case 3: addClocks(24 * 9); break; // 10% speed
}
}
template<unsigned Frequency>
auto SMP::Timer<Frequency>::tick() -> void {
//stage 0 increment
stage0 += smp.status.timerStep;
if(stage0 < Frequency) return;
stage0 -= Frequency;
//stage 1 increment
stage1 ^= 1;
synchronizeStage1();
}
template<unsigned Frequency>
auto SMP::Timer<Frequency>::synchronizeStage1() -> void {
bool newLine = stage1;
if(smp.status.timersEnable == false) newLine = false;
if(smp.status.timersDisable == true) newLine = false;
bool oldLine = line;
line = newLine;
if(oldLine != 1 || newLine != 0) return; //only pulse on 1->0 transition
//stage 2 increment
if(enable == false) return;
if(++stage2 != target) return;
//stage 3 increment
stage2 = 0;
stage3++;
}