tonioni / WinUAE

WinUAE Amiga emulator
http://www.winuae.net/
545 stars 87 forks source link

[bug] Latest WinUAE serial port #252

Closed midwan closed 1 year ago

midwan commented 1 year ago

In the latest WinUAE release (4.10.1), the serial port implementation seems to be somewhat broken, at least in the following scenario:

In the latest version, once you initiate the Link the game responds with "Link complete" but stays there forever.

If we test the same scenario in WinUAE 4.4.0, with the same config as above, the behavior is slightly different / correct. After the Link complete stage, the game proceeds and asks for the name of the driver, on the machine which initiated the link.

I'm attaching the WinUAE config file here, as well. I used the same config file between the tests of 4.10.1 and 4.4.0. StuntCarRacer.zip

midwan commented 1 year ago

Did some more tests today:

Something changing from 4.4.0 to 4.9.x and onwards seems to have broken the serial port comms between WinUAE instances at least.

At the same time, it would be great if this would work when connected with a real Amiga, as well. :)

tonioni commented 1 year ago

If it only affects Stunt Car Racer, it probably is 9-bit serial mode related. Which is a hack in UAE, it splits it in two when sending and receive side merges them back. This is what probably is broken.

PC serial ports don't support 9-bit mode (11 bits total, 1 start, 9 data bits, 1 stop bit, they do support parity as an extra bit but it is generated by the UART and not user controllable) which makes it impossible to have working PC to Amiga connection when program uses 9-bit mode.

midwan commented 1 year ago

@tonioni I think it's more than just Stunt Car Racer (though I haven't yet tested other games):

Based on the above, I think that the chipset rewrite might have broken something that used to work with serial support.

Besides the above and that game, I also tested a serial graphics tablet which works on the Amiga: an Aiptek Hyperpen 4000, using FormAldiHyd by Chris Hodges (http://aminet.net/package/driver/input/FormAldiHyd). I realize this is probably hard for you to test of course, but it also did not work (the program reports no connection), in any WinUAE version from 4.4.0 until the latest.

This might indicate that there's something else "missing" or different, but since this is not a game I am not sure if it's also using the same 9-bit serial mode that you mentioned?

I'll test a few more games when I get a chance, to establish a better sample of what works or not.

tonioni commented 1 year ago

I tried USB serial adapter to real Amiga and terminal program running on both UAE and real Amiga. Serial port seemed to work perfectly fine.

midwan commented 1 year ago

@tonioni Did you try any games? How about Stunt Car Racer specifically? That used to work in 4.4.0, but not since 4.9.x, when using 2 WinUAE instances (on different machines), or Amiga to WinUAE.

tonioni commented 1 year ago

Don't have multiple USB RS232 adapters (yet).

More details needed. Does same happen in cycle-exact and non-CE approximate CPU speed modes? What was first WinUAE beta that introduced the problem? (check EAB beta threads for beta download links).

(SCR still isn't going to ever work because no PC serial port or adapter supports 9 data bit mode. Unless someone creates MCU based custom adapter)

midwan commented 1 year ago

I'll do more tests and provide more details, no problem. Regarding SCR, did you miss the part where I mentioned it is working, with WinUAE 4.4.0? I used the default Quickstart settings for A500 for this game, just enabling the serial port and nothing else (leaving RTS/CTS on).

I will also test some more games and see what happens.

midwan commented 1 year ago

I run a few more tests, so here are the results:

WinUAE <-> WinUAE (2 different PCs, connected with USB to serial and null modem cable)

If you need more examples, I can test more of these :)

midwan commented 1 year ago

@tonioni I went through the different betas, and I found the one that started breaking things:

4920b2

Up to 4920b1 Stunt Car Racer, Lotus and Knights of the Sky still work, but with 4920b2 onwards they shows the above problematic behavior.

midwan commented 1 year ago

@tonioni And the actual line that breaks it, in serial_win32.cpp, is this:

in uae_u16 SERDATR(void):

if (!data_in_serdat || (ser_accurate && get_cycles() >= data_in_serdat_delay)) {

if I change it to:

if (!data_in_serdat && (ser_accurate && get_cycles() >= data_in_serdat_delay)) {

then it works as expected.

tonioni commented 1 year ago

Thanks. Fix commited (that also works when ser_accurate == not cycle-accurate mode is false)

midwan commented 1 year ago

Great, thanks! I'll merge these changes in Amiberry as well!