Thursday, July 17, 2014

Serial Flow Control RTS in QBasic

Flow control is pretty important everywhere in life, and serial communications are no exception.




"Speed it up a little!"


Since my jx-80 simulator in Qbasic is slow and so is my old-school win98 laptop, it can't keep up with 9600 bps data. So I had to struggle to find a way to do it. I got a clue from the online help that had a little example of setting DTR with the INP function.

PRINT "set dtr"
x% = INP(&H3FC)
OUT &H3FC, (x% OR 1)

Well I tried this and it didn't work quite right, seeming to drop characters and get confused.

So I searched some more and came across a really nice book called "Interfacing the IBM-PC to Medical Equipment: The Art of Serial Communication" on Google Books.



On page 73 it has a nice diagram of the Modem Control Register and shows bit 0 is DTR and bit 1 is RTS. So I set and cleared the RTS and it worked great! My logic is to clear RTS when the buffer gets above 5000 bytes and set RTS when the buffer drops below 4000 bytes.

PRINT "set rts"
x% = INP(&H3FC)
OUT &H3FC, (x% OR 2)

PRINT "clear rts"
x% = INP(&H3FC)
OUT &H3FC, (x% AND (255-2))


Without the flow control, the buffer happily goes up to 65535 and overflows. Before this, I put some code in to watch the buffer when it hits 55000 and to stop drawing to the screen to speed it back up. But I think proper flow control is much better.

I think it really would not have been difficult to add commands to handle setting and clearing the RTS and DTR bits in QBASIC.



here you can see the clearing of RTS when we cross 5000 bytes and also the setting of RTS when we drop below 4000 bytes.



The picture finishes normally! The buffer display on the bottom line reads zero.

I see that on ebay they want an arm and a leg for the book. It's a good book, I'm not sure I'd pay $100-200 for it.





Anyway the latest version of my QBasic epson simulator (Epson91.BAS)



Friday, July 11, 2014

Okimate 20

Just for fun I thought I'd have a go at trying to render output from the Amiga Okimate 20 printer driver. This printer is a strange beast. Apparently, you issue ESC CHR(25) commands to reset the color to yellow, and then after you issue a CR it changes the color and prints in magenta, issue another CR and it switches to cyan. After those 3 passes you issue CR LF and then do a ESC CHR(25) again to restart the process.

It has a horizontal graphics resolution of 120 dpi for 960 pixels across. It has a 24 pin mode to print 24 pixel strips.

ESC % O puts you into graphics mode and then byte0 and byte1 for the number of horiz pixels (byte0 + byte1*256). Following this you have 3 bytes for each 24 dot vertical pixel strip.

I can feel the virtual thermal ribbons burning a hole in my virtual pocketbook as it renders the prints. Goodness, they must have been expensive to print full page graphics. 3 pages must have about wiped out a single ribbon. Reminds me of my old Casiowriter thermal typewriter that had these film ribbon cartridges that would be good for about 10 pages.

If you're curious I got the information about the printer from:

http://www.myokidata.com/om20ibm.nsf/InsideUsersManual

I think I only implemented 3 codes: ESC CHR(25), ESC %O, and ESC J (advance n/216).

All the ESC programming codes are nicely summarized on this page:

http://www.myokidata.com/om20ibm.nsf/MOCContents/F5982DA819FFFAAF8525634800547D3D?OpenDocument





Okimate 20 javascript interpreter

Thursday, July 10, 2014

Getting the Amiga to print to the Imagewriter 2

I got winuae to print to the windows com port hooked up to my old laptop running a simple qbasic serial capture program. Running "graphicdump 640:512" does a pretty good rendition of the 640x256 workbench screen at 640x512 printer resolution.




A simple QBasic program to capture the serial port data and write to a file.


I suppose I could always use the CMD utility on the Workbench disk to redirect the Amiga printer output to a file. But where's the fun in that?

Wednesday, July 9, 2014

ImageWriter Interpreter

I always liked the Apple imagewriter printers, probably because we used them at school, and because they were always closely matched with the apple ii. So I thought I'd see if I could interpret some of their ESC codes. The code just implements enough to make some pictures and maybe some pica 10 cpi text.

I seem to have some trouble getting the full 8 bits of data out of the Apple II version of the New Print Shop running under emulation. I was using AppleWin under Wine under knoppix to output the data. It probably didn't help that the New Print Shop would crash when trying out some of the different interface cards. I look at the data and it seems to be missing the high bit (MSB) and the maximum value has 7F.

The code is really ugly with plenty of vestigial junk from my jx80 interpreter. Again, just a proof of concept, and more for fun than anything else.

Looking closely at the ribbons I notice that they have Red, Blue and Yellow to make RYB colors, not CMYK. But I'll cheat a little and treat it as CMYK anyway. I can't wrap my head around the RYB to CMYK conversion just now.

It's interesting that the CUPS linux drivers don't seem to support the color printing ability of the Imagewriter II. Windows doesn't seem to support the color printing capability either with the C.Itoh 8510 driver. Where's the color printing love??? Maybe it's just too low-resolution. *sigh* Next step: Fire up winuae and see if I can make some color printouts.

Runs best under chrome, ok under firefox/iceweasel, and probably terrible under internet explorer (because I don't test it with internet explorer).




imagewriter javascript