Thursday, 31 August 2023

Z88 serial before and after OZ upgrade

Detailing my further adventures with the Z88, both before and after getting the Rakewell Flash Card/OZ 4.7.1 upgrade.

Just a little note first. I changed the batteries first time. To my joy, the capacitor held the charge long enough and no memory was erased.

But it did behave weirdly at first. The screen refused to light, and when I got it running the system began to complain about BAT LOW fairly soon. But this was a false alarm, the computer began behaving normally and the battery alarm was removed.

Serial port

As with pretty much everything about Z88, this is already rather well documented in a number of places and I'll just relate my own experience.

Here I'm first discussing the Z88 without the OS upgrades, then with the OS upgrade that improves the serial performance and has Xmodem and Ymodem protocols.

This is how I soldered the cables, and it seemed to work.

Nominally the standard Z88 can handle 9600 and faster, but for receiving data the Z88 cannot handle the speed and presumable the buffer becomes overrun very quickly. I had to add delay of at least 5 milliseconds after each character to get the transfer to work.

Furthermore, without any protocols, binary bytes have to be sent as [ESC]B [High][Low] so [ESC]B1F means sending 0x1F over. This means sending 4 times the data you mean to send! 

The ultimate test was sending the binary of the Jet Set Willy conversion over, called jsw.c. This is 19388 bytes long. Using the binary method, the overall data sent is 77552 bytes! Using the reliable 5 millisecond delay gives 387.76 seconds of "loading" time, nearly 7 minutes.

The speed can be improved slightly by sending ASCII 32-127 as direct characters, and 0-31 and 128-255 in this binary mode. However you'd expect less than 50% of data in a binary file to fall within the 32-127 range. For example the jsw.c file has 12941 bytes to send in binary mode and only 6447 direct characters. So the data-to-send is reduced from 77552 to 58211 which is still quite ridiculous for a 20K file.

JSW has to scroll or squish on the Z88

Later, with my upgraded Z88 I was accidentally using only 1 millisecond delay for transferring files in 9600 baud rate to the Z88, and it worked well enough.

All this became rather academic as the OZ 4.7 has built-in X/Y modem protocols, which are both faster and more reliable.

With Xmodem you have to type in the filename to be received, and the file lengths may be mis-adjusted to multiples of block length. With Ymodem both these problems go away, and also I don't have to bother about the "4 bytes to send 1 byte" dilemma as all is transferred in binary.

Receiving the 19388 bytes of jsw.c took a little under 30 seconds in 9600 baud. I got closer to 15+ seconds using 19200. I did experience some hiccups in getting the Z88 to catch the file in the first place, though.


Getty

I used getty to give login access to the Linux computer through the USB-COM adapter.

Initially this looked fine as the login and password prompts appeared and I was in.

Again, using 9600 on the basic Z88, any commands that produced more text, for example, listing the folder using ls, or using "more" to display a plain text file, would overrun the buffer.

Upgrading a Linux remotely

So, switching to 2400.

sudo /sbin/agetty 2400 ttyUSB0 vt52

...yielded better results. Keys like TAB don't seem to work and, what would you use for Control? Apparently nothing, although these should be alterable from the receiving end.

Trying getty with the Upgraded OZ 4.7 did not behave better, 9600 was still unusable and I had to revert to 2400. This was a little surprising, not sure why this should be.


The upgrade itself

The Rakewell Flash/512K RAM card fits into the Z88 card slot. The Flash portion can be semi-permanently written and the content won't be destroyed even if the batteries run out. There's a bunch of RAM so it's unlikely I need to keep the other cards in.

Importantly, this card also holds the operating system version 4.7, without having to do any changes to the insides of the Z88.

The physical cartridge is a 3D print which is fine, although not as smooth as the original Cambridge cards. When it is mounted I'm not going to see it anyway.

There are now multiple keyboard settings, which makes sense as there's no point in compiling the ROM for different Z88 keyboard. So I can choose Finnish keyboard. The funny thing is the keyboard layout choice also affects language in date displays etc., it's a nice bonus but really ought to be separate.

New functions relate to the flash card, as it's now possible to haul files from the flash card over to the RAM, but also "burn" files to the flash, just as the EPROM cards supposedly worked. Again, deleting the files will not actually remove them but mark them away from the flash card list. So, eventually the space will run out and it may need reformatting. Luckily this can be done from the system itself, but I'll discuss it more if that day arrives.

I can also appreciate that files can be peeked with a hex/ASCII viewer.

BBC BASIC has been given that graphics patch built-in. Use MODE 1 to activate, the screen is split into text portion and a 256 x 64 "graphic window". 

It's not very fast

There's a bundle of applications and files already on the Flash card, including unzip/zip applications, ROM/EPROM digging and utilities for memory monitoring and disassembly. Some of the material is zipped, and it gives a kind of early 1990s feeling, delving into the text and materials an waiting for zips to unfold.

But if a plain Atari ST was slow at unzipping, then obviously a slightly compromised Z80 chip is going to be even slower! Luckily the files are not very large.

Sidenote: Chezz

One thing I wanted to try is the Chess program, converted from ZX Spectrum Cyrus chess. Previously there was no way to run it, because it was not possible to "install" software from RAM. 

It's chess alright

This was a huge process, as on the Linux side I compiled mpm-master, z88card-master, mthtoken-master, and then z88chess-master to get the chezz.app, chezz.ap0  and chezz.ap1 files. Then I transferred them via the serial to the Z88, selected the .app in Filer and used the <>INS command to install the application. After this it will be listed in the Index.

When listed alongside other applications it can be run. The screen is small and I'm forced to use the arrow keys to enter my moves. Fortunately the sound can be turned off! Playing a couple of fast games, I both won and lost to level 2.

Crashing?

After using the card, I experienced PipeDream crashing, even without doing much else with the computer after the hard reset. It happens rather often, and this is a little sad as I encountered nothing like that before, and I mostly used PipeDream before the upgrade.

The Z88 just becomes unresponsive, no keys work and I have to do a soft reset. The cursor keeps flashing, and if the beep is on the key presses cease to beep. The flashing cursor might not be indicative of anything really, it might be even a part of the LCD features.

I have no way to make really sure if the card is faulty or the computer has a problem which only becomes apparent with the card.

I resorted to using Diary app for random typing, which did eventually crash too, but far less often than with PD.

In Summary

I had good fun exploring the new capabilities of the system and the card contents. Much of it is interest only to developers and tinkerers, but the basic premise of Z88 is already greatly improved with the better comms section. I'm also hearing the OZ 5.0 might be arriving, overhauling many a thing in the process.