[QUOTE=rafan;41731]Hi Brunnis,
Thanks again for all the research you’re doing.
Could you possibly explain again why your bsnes-mercury fix is working? With some of the explanation you gave I’m still a bit puzzled how and why it works. But I’ll try my best to word it like I see it now. Please comment if this is the correct view.
If I would take the perspective of a real SNES (for simplicity take only 240 line case), if I understand you correctly then a real SNES:
- polls input at first line when entering vblank (this is line 240)
- does all game logic in vertical blank (timewise equivalent of about 22 lines, consisting of say 2 lines frontblanking, 3 lines vsync, rest back blanking)
- scans out a raster that displays 240 lines (counting from 0-239) sequentially
Step 1-3 is what we call a frame and a real SNES takes about 16,67ms for each frame. It does this 1-3 cycle over and over until the player turns off the console.
Now I make the step to emulation. The emulation of Step 1 to 3 above on a fairly beefy PC would take about 2 ms for each SNES frame.
The host PC emulating the SNES does this each frame:
- get input state
- run emulation (steps 1-3 above)
- get into a waiting loop (of about 14ms when emulation took 2ms) until host PC screen vertical blank / vsync is reached
This is what we call a frame in the host PC context. It does this frame generation cycle over and over until user quits emulation.
If I understand you correctly your fix for BSNES is purely focused on Step 2 of Host PC context. Taking that Step 2 in Host PC context apart, we get the 1 -3 cycle as mentioned for real SNES. (Only difference is that it takes ~2ms for each 1-3 cycle instead of original ~16,67ms)
Byuu decided to program his emulation such that he gets the PC host input state at line 241, which is one line after where a real SNES gets the input state. Getting the input state at line 241 and not at 240 actually means that the game logic for that frame doesn’t take into account the host PC input state that was read at step 1. It actually takes until the next run of the game logic (one host pc frame later) for this input to be considered, thus causing the extra frame of delay in BSNES. Your fix moves the input polling event to before that line 240, to make sure game logic always gets fed the most current input state (read at step 1 of host PC -current- frame cycle).
Please let me know whether this is the correct understanding of how your fix shaves off one frame of delay in BSNES-Mercury.
P.S. Thanks again for all the informative posts you made, it really helps in getting a better understanding of how these things are related to one another.[/QUOTE] Yes, that’s pretty much exactly what the fix does. Just to be clear, though, I just moved the loop entry/exit point to line 240 or 225 (depending on overscan setting) instead of 241. The emulator itself reads/polls the input at exactly the same place within the SNES frame as before.