I've reached the point where I can have a nice game of chess. My favourite chess game for RC2014 is Sargon 2 for CP/M.
Trying to use the teletype with this game raised a few issues.
The first is the old CR/LF issue. This is a dog's dinner in computing generally and it's no wonder that it has its own page on Wikipedia.
These two characters need to be handled differently on the sending and receiving sides.
Initially I was sending both CR and LF when the return key is typed on the keyboard because this seemed right. But there's a specific issue with CP/M that makes CR-only more appropriate. That seems to work fine with SCM and other software so I'm going with that.
On the receiving/printing side though, it seems that CR, LF and other nonprinting characters need to be handled appropriately.
Initially, I was using a CR to detect the end of a line and print it. This works most of the time, because usually a CR+LF terminates a line. But sometimes they're used separately and have different meanings. I've found that it's better to observe the LF to trigger that line print than CR.
Sargon's output on paper was a mess to start with. Verbose with a lot of repetition.

Using a diagnostic tool that allows me to see the actual nonprinting characters being sent, I could see that it's making liberal use of carriage returns, linefeeds and backspaces to format the output.

For example, when making its own move, it's showing its working by printing the move that it's currently considering, then using a baffling mix of backspaces and CR to go back and overprint with the next possible move (or sometimes just repeat the same thing). This works on a video screen; it acts as a progress indicator as well as giving you the opportunity to see all of the moves that it's considering.
However, with this printer I can't overprint on the same line, even if I want to. It prints pixel row by pixel row and there's no going back.
One option is to add the linefeeds and print all of that out so that you can read it all. But I decided it was best to save paper and observe all of the backspaces and carriage returns. my software doesn't actually send anything to the printer until there's a full line (or a LF).
This works nicely and the result is quite neat, just echoing the player's move and showing the computer's chosen move. (Often you have to use the paper-advance button on the printer because the line it has just printed is hidden until it advances another line).

Another issue is that Sargon2 clears the screen three times during startup using a bunch of linefeeds. This is a waste of paper (which is easy to get but isn't cheap).

I've decided to intercept multiple linefeeds with no printable characters and print a maximum of one empty line at a time. This is a little more tricky than it sounds because of the program flow, but I'll sort that out.
On the hardware side, I've received and fitted the stablisers to my keyboard, which has improved it. I now know more than I wanted to about how these things fit.


Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.