TEXT81 - ZX81 to PC text conversion!

Discussion about ZX80 / ZX81 Software
Post Reply
PrimitivePerson
Posts: 17
Joined: Fri Oct 22, 2010 6:55 pm

TEXT81 - ZX81 to PC text conversion!

Post by PrimitivePerson »

TEXT81.P
ZX81 text to PC .TXT file converter
(2.67 KiB) Downloaded 311 times
One of the killer features of the ZXpand interface is the ability to save chunks of code from memory to the SD card - something the original ZX81 obviously lacked. This got me thinking - given that you can now save raw data from a ZX81, rather than just BASIC programs, you can potentially make use of standard PC file formats, and use it to move all kinds of data back and forth from the ZX81 and PC.

So...I decided to have a stab at writing a program that takes text input from the ZX81, and converting it into a PC-compatible .TXT file that will open up in Notepad. Pointless, yes. Time-consuming, yes. Possible? Yes!

The .TXT file format is, thankfully, very simple. Even so, you can dispense with all the technicalities - a file with a .TXT extension will by default open in Notepad, regardless of what's in it, and the ASCII characters for its contents will be displayed.

Biggest problem here, of course, is that the ZX81 doesn't use ASCII, but has it's own very non-standard character set.

Not a problem - just knock together a program that takes a string, analyses each character, and converts it. That's what I've done - see attached. It works by taking what you type into the INPUT statement, taking each ZX81 character value, converting it to the ASCII character value, and then poking it into memory. When it finishes poking, the ZX81 saves the data as a memory contents file with a .TXT file extension - and when you pop the SD card into your PC and click on it, it opens. Perfectly.

Line 3000 in the program sets the directory on the SD card for the .TXT file to "PC", as that's how I have my card set up, but obviously you can change this.

The way I've set this up, standard upper-case letters on the ZX81 convert into lower-case letters on the PC file, and inverse-video characters are upper case. All the ZX81's standard characters convert. Doing the letters and numbers was easy as they're in blocks that translate simply enough to ASCII, but the punctuation was a pain in the arse, because the ZX81 and ASCII punctuation characters are in a completely different order. This massively slows the program down and makes it pretty clumsy.

On top of the ZX81's normal characters, shift-graphic 1 produces an apostrophe, inverse-full stop produces an exclamation mark, and the keyword AT (function-C) produces the "@" symbol. I'll add more when I find the time. To get the " symbol, use inverse-" rather than shift-q (it just seemed easier to do it that way).

Anyway - I hope you have fun with this. Any suggestions on how to make it work better, or on a better way to get text in (obviously using INPUT limits you to 700 or so characters) would be welcome.

Enjoy. :)

Lee
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: TEXT81 - ZX81 to PC text conversion!

Post by Andy Rea »

from your description your doing the conversion from Zeddy text to Ascci text on the fly in the zeddy right ? and in basic ?...

what i would do is store the zeddy text as is, and then when your done (you can preview it this way too) before saving to SD call an MC routine to convert the bytes, will be much faster than the basic equivalent.

it shouldn't be too hard to knock something up

Andy
what's that Smell.... smells like fresh flux and solder fumes...
PrimitivePerson
Posts: 17
Joined: Fri Oct 22, 2010 6:55 pm

Re: TEXT81 - ZX81 to PC text conversion!

Post by PrimitivePerson »

Andy Rea wrote:from your description your doing the conversion from Zeddy text to Ascci text on the fly in the zeddy right ? and in basic ?...

what i would do is store the zeddy text as is, and then when your done (you can preview it this way too) before saving to SD call an MC routine to convert the bytes, will be much faster than the basic equivalent.

it shouldn't be too hard to knock something up

Andy
I've never done anything with machine code, so wouldn't know where to start - yeah, it's all in BASIC. What it does is take text via an INPUT statement, then when you hit Newline and it moves on, it goes into a FOR-NEXT loop that converts one character at a time. So not on the fly - it gets the text first and then works on it. A paragraph of about a third of the screen takes a minute or two in FAST mode to convert.

Lee
RWAP
Posts: 1348
Joined: Thu May 08, 2008 8:42 am
Location: Stoke-on-Trent, UK
Contact:

Re: TEXT81 - ZX81 to PC text conversion!

Post by RWAP »

Even if you didn't want to do it in machine code, surely it would make better sense to store the text as is, on the ZX81 side of things, and then write a program which can take any stored ZX81 file and convert the characters (which overcomes the limit on entered lines) - the program could be written in ZX BASIC, to run on the ZX81, or even EightyOne, or written in a language on the PC.

Was there never a text editor produced for the zX81 which could make creating the text file a lot easier ?

The challenge is to get it running on the ZX81 I know
PrimitivePerson
Posts: 17
Joined: Fri Oct 22, 2010 6:55 pm

Re: TEXT81 - ZX81 to PC text conversion!

Post by PrimitivePerson »

Well, I just used INPUT as a quick and dirty method of getting data in quickly to check it all works, but it would be cool to use a better text editor. Could this be used with the ZX81 version of Tasword?

Lee
angus
Posts: 142
Joined: Mon Jun 20, 2011 1:28 pm

Re: TEXT81 - ZX81 to PC text conversion!

Post by angus »

I was thinking of writing something like this, but you've beaten me to it.

Maybe of little practical use but fun nonetheless to make files on the Zeddy which are read on the PC.
User avatar
yerzmyey
Posts: 1240
Joined: Thu May 15, 2008 10:11 am
Location: Rubber Planet
Contact:

Re: TEXT81 - ZX81 to PC text conversion!

Post by yerzmyey »

PrimitivePerson wrote: So...I decided to have a stab at writing a program that takes text input from the ZX81, and converting it into a PC-compatible .TXT file that will open up in Notepad. Pointless, yes.
Lee
Well, not necessarily!
It's kind of notepad actually. Which could be useful.
There is a habit on 8bit/16bit parties and meetings - so-called "real-time text".
There is always one computer standing on the party-place for all people to write down their stupid texts into the real-time txt.

I assume Your prog saves the TXT after the ENTER.
If it would save _the same_ text but with more and more addintions, into one and the same file, then it would be interesting thing. That's the first use.

And the second one is obvious - a notepad. But in this purpose You'd have to add some regular SAVE/LOAD module. With "name file" and so on.
IN NIHILUM REVERTERIS - a big text-adventure game for ZX81: http://tiny.pl/g2m6m
"MONOCHROME" issue 5 - (Spring 2014) free paper/PDF magazine about ZX81: http://tiny.pl/q2m44
ZX81 COMPETITIONS 2007/2009: http://zx81.republika.pl/
User avatar
siggi
Posts: 990
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: TEXT81 - ZX81 to PC text conversion!

Post by siggi »

Only for information:
I have written a "printer driver" for ZeddyNet, which allows to redirect the "PRINT" data of a Zeddy to be written as plain ASCII text or to be coded to be used with a ZX81-True-Type-FONT (to be able to display all ZX81 graphic characters in e. g. a windows text processor) via Ethernet to a TNFS fileserver.

I use this e. g. to make program listings with ASDIS on my Zeddy and "print" the listing into a text file on my PC.

The patched rom I use in my Zeddies has a modified print routine. When data has to be printed, the print routine passes the data to the "printer driver". Depending on the printer driver (running at $a000) the data is sent to an ASCII printer, or to the Sinclair printer, or (via a SIO) to a terminal, and now also to a fileserver. So I can use every ZX81 program, which "prints" data (e. g. TASWORD) to create a text file on my PC.

The printer driver and links to the ZX81-TTF-font are in Tom's forum:
http://forum.tlienhard.com/phpBB3/viewt ... ?f=2&t=655

Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
User avatar
yerzmyey
Posts: 1240
Joined: Thu May 15, 2008 10:11 am
Location: Rubber Planet
Contact:

Re: TEXT81 - ZX81 to PC text conversion!

Post by yerzmyey »

PrimitivePerson wrote: So...I decided to have a stab at writing a program that takes text input from the ZX81, and converting it into a PC-compatible .TXT file that will open up in Notepad. Pointless, yes. Time-consuming, yes. Possible? Yes!
Enjoy. :)
Lee

Haha, dude - finally I was able to test it. :)
It roxx!! ;)
IN NIHILUM REVERTERIS - a big text-adventure game for ZX81: http://tiny.pl/g2m6m
"MONOCHROME" issue 5 - (Spring 2014) free paper/PDF magazine about ZX81: http://tiny.pl/q2m44
ZX81 COMPETITIONS 2007/2009: http://zx81.republika.pl/
Post Reply