bsnes/higan/sfc/cpu/serialization.cpp

116 lines
2.8 KiB
C++
Raw Normal View History

auto CPU::serialize(serializer& s) -> void {
R65816::serialize(s);
Thread::serialize(s);
PPUcounter::serialize(s);
s.array(wram);
s.integer(version);
s.integer(status.interruptPending);
s.integer(status.clockCount);
s.integer(status.lineClocks);
s.integer(status.irqLock);
s.integer(status.dramRefreshPosition);
s.integer(status.dramRefreshed);
s.integer(status.hdmaInitPosition);
s.integer(status.hdmaInitTriggered);
s.integer(status.hdmaPosition);
s.integer(status.hdmaTriggered);
s.integer(status.nmiValid);
s.integer(status.nmiLine);
s.integer(status.nmiTransition);
s.integer(status.nmiPending);
s.integer(status.nmiHold);
s.integer(status.irqValid);
s.integer(status.irqLine);
s.integer(status.irqTransition);
s.integer(status.irqPending);
s.integer(status.irqHold);
s.integer(status.powerPending);
s.integer(status.resetPending);
s.integer(status.dmaActive);
s.integer(status.dmaCounter);
s.integer(status.dmaClocks);
s.integer(status.dmaPending);
s.integer(status.hdmaPending);
s.integer(status.hdmaMode);
s.integer(status.autoJoypadActive);
s.integer(status.autoJoypadLatch);
s.integer(status.autoJoypadCounter);
s.integer(status.autoJoypadClock);
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
Updated to v067r23 release. byuu says: Added missing $4200 IRQ lock, which fixes Chou Aniki on the fast CPU core, so slower PCs can get their brotherly love on. Added range-based controller IOBit latching to the fast CPU core, which enables Super Scope and Justifier support. Uses the priority queue as well, so there is zero speed-hit. Given the way range-testing works, the trigger point may vary by 1-2 pixels when firing at the same spot. Not really a big deal when it avoids a massive speed penalty. Fixed PAL and interlace-mode HVIRQs at V=0,H<2 on the fast CPU core. Added the dot-renderer's sprite list update-on-OAM-write functionality to the scanline-based PPU renderer. Unfortunately it looks like all the speed gain was already taken from the global dirty flag I was using before, but this certainly won't hurt speed any, so whatever. Added #ifdef to stop CoInitialize(0) on non-Windows ports. Added #ifdefs to stop gradient fade on Windows port. Not going to fuck over the Linux port aesthetic because of Qt bug #47,326,927. If there's a way to tell what Qt theme is being used, I can leave it enabled for XP/Vista themes. Moved HDMA trigger from 1104 to 1112, and reduced channel overhead from 24 to 16, to better simulate one-cycle DMA->CPU sync. Code clarity: I've re-added my varint.hpp classes, and am actively using them in the accuracy cores. So far, I haven't done anything that would detriment speed, but it is certainly cool. The APU ports exposed by the CPU and SMP now take uint2 address arguments, the CPU WRAM address register is a uint17, and the IRQ H/VTIME values are uint10. This basically allows the source to clearly convey the data sizes, and eliminates the need to manually mask values when writing to registers or reading from memory. I'm going to be doing this everywhere, and it will have a speed impact eventually, because the automation means we can't skip masks when we know the data is already masked off. Source: archive contains the launcher code, so that I can look into why it's crashing on XP tomorrow. It doesn't look like Circuit USA's flags are going to work too well with this new CPU core. Still not sure what the hell Robocop vs The Terminator is doing, I'll read through the mega SNES thread for clues tomorrow. Speedy Gonzales is definitely broken, as modifying the MDR was breaking things with my current core. Probably because the new CPU core doesn't wait for a cycle edge to trigger. I was thinking that perhaps we could keep some form of cheat codes list to work as game-specific hacks for the performance core. Keeps the hacks out of the emulator, but could allow the remaining bugs to be worked around for people who have no choice but to use the performance core.
2010-08-16 09:42:20 +00:00
s.array(status.port);
s.integer(status.wramAddress);
s.integer(status.joypadStrobeLatch);
s.integer(status.joypad1_bits);
s.integer(status.joypad2_bits);
s.integer(status.nmiEnabled);
s.integer(status.hirqEnabled);
s.integer(status.virqEnabled);
s.integer(status.autoJoypadPoll);
s.integer(status.pio);
s.integer(status.wrmpya);
s.integer(status.wrmpyb);
s.integer(status.wrdiva);
s.integer(status.wrdivb);
s.integer(status.hirqPos);
s.integer(status.virqPos);
s.integer(status.romSpeed);
s.integer(status.rddiv);
s.integer(status.rdmpy);
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
s.integer(status.joy1);
s.integer(status.joy2);
s.integer(status.joy3);
s.integer(status.joy4);
s.integer(alu.mpyctr);
s.integer(alu.divctr);
s.integer(alu.shift);
for(uint n : range(8)) {
s.integer(channel[n].dmaEnabled);
s.integer(channel[n].hdmaEnabled);
s.integer(channel[n].direction);
s.integer(channel[n].indirect);
s.integer(channel[n].unused);
s.integer(channel[n].reverseTransfer);
s.integer(channel[n].fixedTransfer);
s.integer(channel[n].transferMode);
s.integer(channel[n].targetAddress);
s.integer(channel[n].sourceAddress);
s.integer(channel[n].sourceBank);
s.integer(channel[n].transferSize);
s.integer(channel[n].indirectBank);
s.integer(channel[n].hdmaAddress);
s.integer(channel[n].lineCounter);
s.integer(channel[n].unknown);
s.integer(channel[n].hdmaCompleted);
s.integer(channel[n].hdmaDoTransfer);
}
s.integer(pipe.valid);
s.integer(pipe.addr);
s.integer(pipe.data);
}