[uae] Re: Network play

  • From: Anders Andersson <pipatron@xxxxxxxxx>
  • To: uae@xxxxxxxxxxxxx
  • Date: Thu, 26 Nov 2009 15:29:36 +0100

On Thu, Nov 26, 2009 at 3:15 PM, Stefan Reinauer <stepan@xxxxxxxxxxxxxx> wrote:
> On 11/26/09 2:57 PM, Anders Andersson wrote:
>> On Thu, Nov 26, 2009 at 12:44 AM, Fabian Zaengel
>> <polterding@xxxxxxxxxxxxxx> wrote:
>>
>>
>>> As far as I could see by now they seem to have taken a different
>>> approach. Instead of transfering the whole buffer frame by frame into a
>>> dummy window they managed to let multiple emulators run synchronized.
>>>
>>> I was thinking about this for a short while too, but withdrew it because
>>> I thought it would be too difficult if not impossible to handle.
>>>
>>> This solution seem to have some of the short-comings I was thinking of
>>> too. f.e. as soon as the game does some 'random' stuff the emulators
>>> will immediately run out of sync, which is generally a problem also for
>>> simple scripted games.
>>>
>> There is nothing random in an emulated Amiga. There cannot be, unless
>> you explicitly attach external physical hardware to the emulated
>> Amiga, through a virtual serial port or similar. This shouldn't be
>> very difficult to set up at all I think. You have to make sure two
>> things:
>>
>> 1) The two emulators start up with the exact same state (every bit in
>> the emulated Amiga memory is identical on both)
>> 2) Whenever there is input of any kind (joystick, keyboard) it has to
>> arrive at both computers at exactly the same cycle.
>>
>> Step one could be done by synchronizing the emulated machines before
>> you start playing. Step two by detaching the input in the emulator and
>> let all inputs go to a server/daemon that will emit signals to the
>> emulator with precise timestamps. This daemon must probably send
>> 'ticks' to both Amigas periodically, and unless a tick is received,
>> the emulator has to freeze and wait for network connectivity again.
>>
> Additional synchronization might be needed. The OS might (for whatever
> reason) interrupt the emulators at different times, so they internal
> states may diverge. Thinking of butterflies, this effect can be substantial.

That doesn't matter, since the emulated Amiga don't have any idea that
it was in fact interrupted, or switched to another CPU, etc. This
might break if the emulator is doing something bad, but since
everything is emulated and nothing is using the real underlying
hardware I can't think of what could cause such a breakage right now.
Everything will still be in sync: CIA timers, internal CPU state,
stacks, CPU cache, custom registers...

If you still disagree, I'm very interested in an example where such a
thing you described can happen, and how it can happen! :)

/ pipe

Other related posts: