ZX81 emulator "command-line edition"

Emulator and emulator development specific topics
olofsen
Posts: 189
Joined: Wed Jan 08, 2014 12:29 pm

ZX81 emulator "command-line edition"

Post by olofsen »

This emulator:

http://rullf2.xs4all.nl/sg/zx81ce.html

is a "command-line" edition, which is not suitable for playing action games, but it is capable of reading BASIC files in ASCII, and producing output in ASCII or in Sixel graphics. The latter can be viewed using newer XTerms and classical DECterms. Somewhat obscure, but perhaps still interesting!
MOB-i-L
Posts: 62
Joined: Mon Apr 19, 2010 12:13 am
Location: Lund, Skåne/Scania, Sweden
Contact:

Re: ZX81 emulator "command-line edition"

Post by MOB-i-L »

I tested it in xterm on Ubuntu 10.04 Linux and it works in text-mode but not with Sixel graphics. Maybe the built-in xterm is not complied with --enable-sixel-graphics. How can I determine if my xterm has Sixel graphics?

I start xterm using:
xterm -ti 340 -xrm 'XTerm*sixelScrolling: True'
Is this correct?

About:
"Commands at the K> prompt:

- when given in uppercase, these are interpreted as BASIC commands;
some commands do not work and have lower case replacements:

- clear, cls, copy (in ASCII), scopy (as Sixels), hcopy (as HTML),
goto, list, llist, new, run, svlist (system variables), vlist (variables)"

Why can one not use e.g. RUN as uppercase. Now you have to toggle the CapsLock very often.

About:
"o Bugs
- When PRINT output is redirected to stdout using the '-r0' option,
function STR$ does not get the correct resultant string length."

I tested without -r0 but still gets the same error:
K> PRINT LEN STR$ 1234
12340
K> PRINT LEN "1234"
4
K> LET A$=STR$ 4321
K> PRINT A$
4321
K> PRINT LEN A$
0

Couldn't this bug be fixed? It is rather serious and could break a lot of programs for the Sinclair ZX81 Personal Computer.
olofsen
Posts: 189
Joined: Wed Jan 08, 2014 12:29 pm

Re: ZX81 emulator "command-line edition"

Post by olofsen »

The command to start XTerm is correct. With ctrl-3rd mouse button one gets the VT options, and option sixelScrolling should be there if it is compiled in.

Indeed - for now I added RUN and GOTO in uppercase.

When using PRINT at the command prompt, it will LPRINT to stdout. "LPRINT LEN STR$ 1234" on the "xz81" emulator gives the same response "12340"...! But I've put a fix in the current source.
MOB-i-L
Posts: 62
Joined: Mon Apr 19, 2010 12:13 am
Location: Lund, Skåne/Scania, Sweden
Contact:

Re: ZX81 emulator "command-line edition"

Post by MOB-i-L »

I don't have any option with Sixel when I Ctrl+left, right or middle click in xterm in Ubuntu Linux 10.04 LTS or Ubuntu 12.04 LTS. I think Sixel-graphics was introduced in 2013.

The README-file is not changed about RUN and GOTO. I think all ZX81-commands that works in programs should exist in upper case on the command-line, since ZX81 doesn't distinguish much between the command-line and the program, i.e. everything you can write in a program you can also enter on a command-line and vice versa (except for commands that depend on other lines in the program).

The fix for LEN STR$ worked.

I think the documentation should be improved so that you don't need to read the source-code in-order to know what you can do.

It would be good if shebang (#!) worked for ZX81 bas-files as for other script-languages, see http://en.wikipedia.org/wiki/Shebang_(Unix). Then you could use ZX81-basic with Z80-machine code as a general script-language in Unix.
olofsen
Posts: 189
Joined: Wed Jan 08, 2014 12:29 pm

Re: ZX81 emulator "command-line edition"

Post by olofsen »

Compiling XTerm could be straightforward:
Download from http://invisible-island.net/xterm/#download
Just ./configure --enable-sixel-graphics ; make
Run the created executable with the options as showed before.

I agree that the available commands and the documentation need some attention.

Shebang is a very good suggestion - I've put a demo in the updated source.
MOB-i-L
Posts: 62
Joined: Mon Apr 19, 2010 12:13 am
Location: Lund, Skåne/Scania, Sweden
Contact:

Re: ZX81 emulator "command-line edition"

Post by MOB-i-L »

I tried to complile xterm with Sixel-graphics and run zce in it, and succeeded.

First, I couldn't run configure, but after

Code: Select all

sudo apt-get install libxaw7-dev
it worked.

I got this error when I run make:
In file included from ./input.c:90:0:
./xtermcap.h:64:20: fatal error: curses.h: No such file or directory
compilation terminated.

But after

Code: Select all

sudo apt-get install ncurses-dev
make worked and I could run the new xterm with Sixel.

I did this on Raspberry Pi with a newly installed Raspbian from NOOBS lite.

Then I also had to

Code: Select all

sudo apt-get install libreadline-dev
in-order to compile zce.

I tested this program:

Code: Select all

  10 PRINT "ZCE"
  20 PLOT 32,22
  30 INPUT A$
  40 PRINT AT 17,10;A$
INPUT doesn't work as expected but starts on a line below the screen, and PRINT AT doesn't show on a screen. Also deleting lines by entering just line-numbers doesn't work (you get an empty line), but you can do e.g. d30 to delete line 30. Also in ZX81 you could bring down a line for editing. I don't have time for more testing now, but will be back.
olofsen
Posts: 189
Joined: Wed Jan 08, 2014 12:29 pm

Re: ZX81 emulator "command-line edition"

Post by olofsen »

Yes, INPUT reads from stdin. And the question is how often to output the screen to the terminal. I chose to output it before an INPUT (unless in pure command-line mode rerouting 0). The "REM $S" command may be used here to output the screen. So the following code would work:

Code: Select all

  10 PRINT "ZCE"
  20 PLOT 32,22
  30 INPUT A$
  40 PRINT AT 17,10;A$
  50 REM $S
I've changed the command line parsing such that when there is only a number, the BASIC line will be deleted. And I've added an "EDIT <lineno>" command, which LPRINTs the line to the readline buffer.
MOB-i-L
Posts: 62
Joined: Mon Apr 19, 2010 12:13 am
Location: Lund, Skåne/Scania, Sweden
Contact:

Re: ZX81 emulator "command-line edition"

Post by MOB-i-L »

I tested shebang with this program:

Code: Select all

#!../zce
# set path to zce and execution bit

10 if not len a$>0 then goto 30
20 print a$;"=";val a$
30 rem

# in bash, use "echo $?" to observe report code
It did work with expressions that don't contain functions or ** (power). I think there is some bug in the tokenization.

Edit works here too and also without a line-number (gets current line)!
When you enter a program it doesn't look like on the ZX81 because you only see the last line, and not the rest of the program. LIST doesn't help -- you have to do LIST 0 but that changes the current line.
olofsen
Posts: 189
Joined: Wed Jan 08, 2014 12:29 pm

Re: ZX81 emulator "command-line edition"

Post by olofsen »

The behavior of the automatic listings should now be more similar, but not yet identical to that of the ZX81 (using variable "s-top").

The tokenizer only worked when compiling a program. So the argument passed via A$ was never tokenized. In addition, strings were not tokenized, because in an ASCII string such as "A AND B" it is not known if this is text or an expression... In the updated source, I added a "-k" option to enable tokenizing strings, while compiling and while getting the command line argument (I will add it to INPUT too). So I hope your shebang will now work if you have "#!../zce -k" as the first line.
MOB-i-L
Posts: 62
Joined: Mon Apr 19, 2010 12:13 am
Location: Lund, Skåne/Scania, Sweden
Contact:

Re: ZX81 emulator "command-line edition"

Post by MOB-i-L »

The ZX81-script with VAL now works! I see you can read and set environment variables but only if they start with ZX and when you set they are not set directly but stored in a file zx81.env which one can run with source. This makes it difficult to use ZX81-scripts as CGI-scripts without using a wrapper in some other script-language, such as Perl or PHP.

When I run ZX81 BASIC-programs as scripts they output mixed-case. I think there should be options to force lower- and upper-case output, respectively.

It is good that the tokenizing of input doesn't distinguish between lower- and upper-case.

It is strange that INPUT A$ can input strings using upper- and lower-case and that PRINT A$ keeps the case. Are the upper-case characters stored as inverted characters?

How is stdout at address 65528 in raw.bas and how can you print to stdout using USR 65527? Doesn't this prevent usage of all RAM. (I have 56KB RAM for my ZX81: 8KB to 64KB-1B.)

Will it be possible to use other ROMs in zce e.g. SPONZY and some Forth-ROM that comes with Eightyone-emulator and ZX80?
Post Reply