onsdag 18 maj 2016

MAME serial support Part II

I have previously submitted a driver for the Zilog SCC, Serial Communication Controller, to MAME, improving it while working on different board drivers needing it. While one would want everything to be emulated correctly from start it crucial to find some legacy code to test the feature at hand. Unless you do the effort is not useful anyway.

Usually a board initiates the SCC and start sending characters through it to an unknown device at the other end. The device on the other end will eventually send something back and the firmware will respond to it. Quite simple ehh!?

The way this is done can differ a lot though and if a feature used is not emulated or previously tested it is important that the board writer get useful messages using the logerror(). I usually start with that, creating logerrors for everything that doesn't work, so when a new software is tested there are printouts saying that this feature is not implemented. Then it is Time to call Saul.

[ The logerrors are seen in the debugger log window. The debugger is enabled by the -debug command line switch from where you start the board driver with F5, but first you want to open the log window by Ctl-L. ]

When writing the board driver for the MVME-147 I had problems getting the keyboard on the terminal to produce input. The funny thing was that the output worked just fine. Hmmm... I had to dive into the core code to understand how this was possible. The core feature that allows us to connect a serial device to a terminal as previously explored is mainly kept in src/emu/diserial.cpp

I had recently added support for SCC:s internal baud rate generator by adding a timer. It worked in the board driver for hk68v10 board but for MVME147 it failed. I pretty soon figured out that the serial timing was not working since I sometimes got a character through but sometimes the system got it wrong by just a bit or so.

I had to investigate it of course and I found several weaknesses of my first implementation in relation to how diserial works and can do for you. Here is my post on the MAMEdev forum summarizing it like this:

"I found the bugs finally, it was due to that it is not possible to use diserial the way I did with local baudrate timer in the SCC device. I got it nearly to work one way as can be seen above but when sending keypresses the other way there was problems. The SCC device wasn't producing exactly the right baud rate but nearly enough to being able to send characters from the board to the terminal, but in the opposite direction there was not start bit detection and there was no mid bit alignment in the SCC device. Even after adding that it turned out that I didn't get the final transmitt_complete because it also had no stop bit detection... So I relized I was reimplementing diserial in the SCC device and after I relized that it took me just 20 minutes to implement the baudrate timer using the diserial setrate() functions. So that part is now rock solid compared to how it was and the MVME-147 driver was submitted a few days ago with a working 147-Bug> terminal."
So to not reinvent the wheel you need to recognize a wheel...

Inga kommentarer:

Skicka en kommentar