Closed colinleroy closed 2 months ago
@rb6502 This seems to be Apple II specific, pinging you in case you inadvertently overlook the report.
@rb6502 This seems to be Apple II specific, pinging you in case you inadvertently overlook the report.
I'm unsure it's Apple II specific. The serial ports for the Apple IIc are defined like this:
MOS6551(config, m_acia2, 0);
m_acia2->set_xtal(1.8432_MHz_XTAL); // matches SSC so modem software is compatible
m_acia2->txd_handler().set("modem", FUNC(rs232_port_device::write_txd));
That's the correct clock rate.
I think it may either be a problem in mos6551.cpp, null_modem.cpp or maybe the bitbanger (which I don't find the source to) ?
Hi,
I've started looking, and it seems I found the cause using this commit: https://github.com/colinleroy/mame/commit/c076ac8adcd496d4429848adeab558f1b728020d
It seems like mos6551.cpp delivers one data byte every 176 clock ticks, which is 95µs at 1.8432MHz. That should be 160 clock ticks (86µs).
I've not yet figured out how the code is wrong but this also explains why sometimes I lose bytes on real hardware and not on emulation.
This commit https://github.com/colinleroy/mame/commit/7e74bcdde8de267d8cc66e732a0198014fb47d8a shows me that we postpone the start bit by 16 ticks because m_rxd != 0.
Still have to find out what calls mos6551_device::write_rxd
and toggles m_rxd.
OK, I figured it out ! PR sent.
MAME version
0.263 (unknown) (0.263+dfsg.1-0ubuntu1~ppa1~mantic1)
System information
Linux Ubuntu 23.04, x86_64, en_US.UTF-8 locale.
INI configuration details
Emulated system/software
apple2c0
Incorrect behaviour
Hi, I am currently developing an audio/video player for the Apple II, and have noticed that MAME is feeding bytes from the bitbangers to the emulated Apple II too slowly.
The symptoms are visible in this demo video : https://www.youtube.com/watch?v=cqWVqEN_OCw It consists of three parts:
A bit more information about the serial emulation: My transcoder gets a video file, transcodes it to a video part and a sound part. The sound part is 5bit, 11520Hz PCM data, and is streamed to the Apple II's modem port, configured at 115200 8n1.
That takes perfect care of the playback speed on real hardware, as 115200 8n1 means 11520 bytes/s, including 1 start bit, 8 data bits, 1 stop bit.
(The video is streamed to the printer port. In this demo it is not slowed down because it uses less bandwidth (~1400 bytes/s), so even if MAME reads it slowly, it's still fast enough to do 25fps).
On MAME, the serial stack is as follows:
-modem null_modem -bitb2 socket.localhost:2000
The last part of my test video is there to verify that the tty0tty + ser2net part of the emulation is not responsible for the slowdown (on the contrary, it is much too fast, transferring 60*11520 'A' characters in less than 6 seconds. This causes me other problems, but they're not MAME-related).
I would love to help fix this, but I have no idea where to start in the code. I hope that, if nobody can take care of this issue for me, maybe someone with a good knowledge of MAME's codebase could point me in the right direction and help me solve it?
Thanks a lot in advance!
Expected behaviour
MAME sends 11520 bytes per second to the emulated serial port.
Steps to reproduce
mame apple2c0 -window -flop1 wozamp-65c02.po -resolution 560x384 -printer null_modem -bitb socket.localhost:2001 -modem null_modem -bitb2 socket.localhost:2000 -nomouse
Additional details
No response