2016-03-26 01:56:15 +00:00
|
|
|
//called every 256 clocks; see CPU::addClocks()
|
|
|
|
auto CPU::stepAutoJoypadPoll() -> void {
|
2016-04-09 05:20:41 +00:00
|
|
|
if(vcounter() >= ppu.vdisp()) {
|
2011-12-12 10:59:53 +00:00
|
|
|
//cache enable state at first iteration
|
|
|
|
if(status.auto_joypad_counter == 0) status.auto_joypad_latch = status.auto_joypad_poll;
|
2011-03-20 13:57:55 +00:00
|
|
|
status.auto_joypad_active = status.auto_joypad_counter <= 15;
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2011-12-12 10:59:53 +00:00
|
|
|
if(status.auto_joypad_active && status.auto_joypad_latch) {
|
2011-06-24 10:43:29 +00:00
|
|
|
if(status.auto_joypad_counter == 0) {
|
2015-11-10 11:02:29 +00:00
|
|
|
device.controllerPort1->latch(1);
|
|
|
|
device.controllerPort2->latch(1);
|
|
|
|
device.controllerPort1->latch(0);
|
|
|
|
device.controllerPort2->latch(0);
|
2011-06-24 10:43:29 +00:00
|
|
|
}
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2015-11-10 11:02:29 +00:00
|
|
|
uint2 port0 = device.controllerPort1->data();
|
|
|
|
uint2 port1 = device.controllerPort2->data();
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
status.joy1 = status.joy1 << 1 | port0.bit(0);
|
|
|
|
status.joy2 = status.joy2 << 1 | port1.bit(0);
|
|
|
|
status.joy3 = status.joy3 << 1 | port0.bit(1);
|
|
|
|
status.joy4 = status.joy4 << 1 | port1.bit(1);
|
Update to v073r01 release.
byuu says:
While perhaps not perfect, pretty good is better than nothing ... I've
added emulation of auto-joypad poll timing.
Going off ikari_01's confirmation of what we suspected, that the strobe
happens every 256 clocks, I've set up emulation as follows:
Upon reset, our clock counter is reset to zero.
At the start of each frame, our poll counter is reset to zero.
Every 256 clocks, we call the step_auto_joypad_poll() function.
If we are at V=225/240+ (based on overscan setting), we check the poll
counter.
At zero, we poll the actual controller and set the joypad polling flag
in $4212.d0 to 1.
From zero through fifteen, we read in one bit for each controller and
shift it into the register.
At sixteen, we turn off the joypad polling flag.
The 256-clock divider allows the start point of polling for each frame
to fluctuate wildly like real hardware.
I count regardless of auto joypad enable, as per $4212.d0's behavior;
but only poll when it's actually enabled.
I do not consume any actual time from this polling. I honestly don't
know if I even should, or if it manages to do it in the background.
If it should consume time, then this most likely happens between opcode
edges and we'll have to adjust the code a good bit.
All commercial games should continue to work fine, but this will likely
break some hacks/translations not tested on hardware.
Without the timing emulation, reading $4218-421f before V=~228 would
basically give you the valid input controller values of the previous
frame.
Now, like hardware, it should give you a state that is part previous
frame, part current frame shifted into it. Button positions won't be
reliable and will shift every 256 clocks.
I've also removed the Qt GUI, and renamed ui-phoenix to just ui. This
removes 400kb of source code (phoenix is a lean 130kb), and drops the
archive size from 564KB to 475KB. Combined with the DSP HLE, and we've
knocked off ~570KB of source cruft from the entire project. I am looking
forward to not having to specify which GUI is included anymore.
2010-12-27 07:29:57 +00:00
|
|
|
}
|
2011-03-20 13:57:55 +00:00
|
|
|
|
|
|
|
status.auto_joypad_counter++;
|
Update to v073r01 release.
byuu says:
While perhaps not perfect, pretty good is better than nothing ... I've
added emulation of auto-joypad poll timing.
Going off ikari_01's confirmation of what we suspected, that the strobe
happens every 256 clocks, I've set up emulation as follows:
Upon reset, our clock counter is reset to zero.
At the start of each frame, our poll counter is reset to zero.
Every 256 clocks, we call the step_auto_joypad_poll() function.
If we are at V=225/240+ (based on overscan setting), we check the poll
counter.
At zero, we poll the actual controller and set the joypad polling flag
in $4212.d0 to 1.
From zero through fifteen, we read in one bit for each controller and
shift it into the register.
At sixteen, we turn off the joypad polling flag.
The 256-clock divider allows the start point of polling for each frame
to fluctuate wildly like real hardware.
I count regardless of auto joypad enable, as per $4212.d0's behavior;
but only poll when it's actually enabled.
I do not consume any actual time from this polling. I honestly don't
know if I even should, or if it manages to do it in the background.
If it should consume time, then this most likely happens between opcode
edges and we'll have to adjust the code a good bit.
All commercial games should continue to work fine, but this will likely
break some hacks/translations not tested on hardware.
Without the timing emulation, reading $4218-421f before V=~228 would
basically give you the valid input controller values of the previous
frame.
Now, like hardware, it should give you a state that is part previous
frame, part current frame shifted into it. Button positions won't be
reliable and will shift every 256 clocks.
I've also removed the Qt GUI, and renamed ui-phoenix to just ui. This
removes 400kb of source code (phoenix is a lean 130kb), and drops the
archive size from 564KB to 475KB. Combined with the DSP HLE, and we've
knocked off ~570KB of source cruft from the entire project. I am looking
forward to not having to specify which GUI is included anymore.
2010-12-27 07:29:57 +00:00
|
|
|
}
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|