ZX81 BASIC

Anything QL Software or Programming Related.
User avatar
bwinkel67
QL Wafer Drive
Posts: 1196
Joined: Thu Oct 03, 2019 2:09 am

ZX81 BASIC

Post by bwinkel67 »

Starting this topic here to get some help. I know there are forums out there for the ZX81 and its emulators and I have started reading them but not ready to join another forum as then I'm spending too much time on two :-/

My plan is to turn my BASIC interpreter (check out viewtopic.php?f=3&t=3169 though it kind of got off topic regarding random number generation) into a ZX81 BASIC interpreter that could then run any BASIC game on an unexpanded QL.

So the natural question is why oh why? I know there already is a ZX81 emulator that will do that on a Gold Card QL or anything higher. Well, it's a hobby and it might be neat to recreate the ZX81 BASIC and I already have a working interpreter written in C (Digital C to be specific) that presently does integer BASIC (need to add floating point which I did back in the 90's when I ported it to the Mac) and does more of its BASIC things ZX81-like than QL-like (feel free to look at it as I distributed the source). For instance, I use GOTO not GO TO. Don't even know how I missed that the QL splits it up. I figure all I need to add in is the graphics and then might have a pretty peppy running (what I call) simulator on an unexpanded QL. It wouldn't run machine code programs but should run BASIC ones.

First task, reclaim some of my BASIC programs I still have on tape. Back as a teenager I wrote a few including a terminal program, an assembler, a text editor, and a game called Battleship. The latter I was in negotiation with one of the US distributors to sell right around the time Timex pulled the plug in the US. Ugh, a year too late. But it was fully written in ZX81 BASIC with 16K RAM pack and it had some cool graphics and played pretty nicely. I kind of want to see it running in my ZX81 simulator on the QL -- that's the goal.

First off, in the ZX81 community they have tools to take audio files and load them in to EightyOne (I'm using v0.43c), which seems to be the best emulator out there -- I'm wondering if it is related to the Spectrum Next project since it can emulate all of those machines. So figuring out how to read in a wave file and then convert it to a .p file so another tool (zxlist64) can convert it to text has not been trivial. Does anyone on this forum have any experience with the emulator? Just to understand the difference between .p and .z81 and .t81 and .tzx files has been a bit of a headache. It's unclear how to go from one to the other though I do understand some are collections of BASIC programs: like an entire cassette vs a program on a cassette -- is that what the "p" and "t" stand for, (p)rogram vs cassette (t)ape?

I could re-type my game in but who wants that. One nice thing, they have ASCII representations of the ZX81 graphic character set so I don't have to recreate the wheel.


swensont
Forum Moderator
Posts: 252
Joined: Tue Dec 06, 2011 3:30 am
Location: SF Bay Area
Contact:

Re: ZX81 BASIC

Post by swensont »

ZX81 Basic is very similar to Spectrum Basic. There has already been some work done on Spectrum Basic interpreters for other systems.

Paul Dunn has written SpecBAS. Made for Windows with an older port to Linux.
https://sites.google.com/site/pauldunn/

Philip Kendell has written BASIC and CheckBasic. CheckBasic is a Spectrum syntax checker. BASIC is an interpreter. Both are for Unix/Linux.
http://www.shadowmagic.org.uk/spectrum/checkbasic.html
http://www.shadowmagic.org.uk/spectrum/basic.html

Tim


User avatar
bwinkel67
QL Wafer Drive
Posts: 1196
Joined: Thu Oct 03, 2019 2:09 am

Re: ZX81 BASIC

Post by bwinkel67 »

Thanks. My plan is to convert the BASIC I have to ZX81 BASIC as a fun project. My questions are more on how to convert old-school cassette software into text software.


swensont
Forum Moderator
Posts: 252
Joined: Tue Dec 06, 2011 3:30 am
Location: SF Bay Area
Contact:

Re: ZX81 BASIC

Post by swensont »

A lot of the ZX81 software has been converted to .P or .81 files. There is zxlist (by Jack Raat iirc) and it will convert .P to a text file of Sinclair BASIC. If you need to convert your own cassettes, there is some software for Windows that will convert audio input (from a cassette player) into a .P or .81 file. I've never done it, but you can search online for such a thing.

Tim


tcat
Super Gold Card
Posts: 633
Joined: Fri Jan 18, 2013 5:27 pm
Location: Prague, Czech Republic

Re: ZX81 BASIC

Post by tcat »

My plan is to convert the BASIC I have to ZX81 BASIC as a fun project. My questions are more on how to convert old-school cassette software into text software.
I cannot tell about ZX81 tape files. But for ZX Speccy taps, these utilities can be used.

zmakebas - convert text files into ZX Spectrum Basic programs
$ apt-get install zmakebas

or from source
https://derekbolli.wordpress.com/2012/1 ... -zmakebas/

makeTZX - make tzx file from audio line in
http://ramsoft.bbk.org.omegahg.com/maketzx.html


User avatar
Chr$
QL Wafer Drive
Posts: 1306
Joined: Mon May 27, 2019 10:03 am
Location: Sachsen, Germany
Contact:

Re: ZX81 BASIC

Post by Chr$ »

I've recovered some old ZX81 tapes in the past by recording the audio as a wav, then loading them into the emulator '81' and from there saving is as .p (or a much better quality wav file if I want to actually load it on a real ZX81). It isn't immediately obvious how to do it, but it works. From memory I think you have to create a new tape, then enter SAVE "name" and then save that output as a .p from the virtual taperecorder.


https://QXL.WIN
Collector of QL related computers, accessories and QL games/software.
Ask me about felt pads - I can cut them to size and they have proved excellent for mdv data recovery.
User avatar
bwinkel67
QL Wafer Drive
Posts: 1196
Joined: Thu Oct 03, 2019 2:09 am

Re: ZX81 BASIC

Post by bwinkel67 »

Yes, that process of loading a wave file and converting into a .p file is elusive and not very clear. When you open the manager, on many occasions it only gives you.t81 and .tzx file choices and I haven't figured out yet how to have it come up with the .p option. I even followed ZX forum step-by-step instructions and still nothing. Just something I must be missing. I do have the source code printed out on one of those metallic papers that the ZX81 used to print on so likely that copy is still very readable and I might just re-type it (ugh). We're on spring break next week and the way things are going in the US we may not open up again for the rest of the school year so I will have time to look at that :-/


User avatar
bwinkel67
QL Wafer Drive
Posts: 1196
Joined: Thu Oct 03, 2019 2:09 am

Re: ZX81 BASIC

Post by bwinkel67 »

swensont wrote:ZX81 Basic is very similar to Spectrum Basic. There has already been some work done on Spectrum Basic interpreters for other systems.

Paul Dunn has written SpecBAS. Made for Windows with an older port to Linux.
https://sites.google.com/site/pauldunn/

Philip Kendell has written BASIC and CheckBasic. CheckBasic is a Spectrum syntax checker. BASIC is an interpreter. Both are for Unix/Linux.
http://www.shadowmagic.org.uk/spectrum/checkbasic.html
http://www.shadowmagic.org.uk/spectrum/basic.html

Tim
Hi Tim,

I finally got a chance to look at all these links and they are mostly dead when you try and download the code. I think the only one I found was the Raspberry Pi version of SpecBas. Tried looking for other sites that held those but I guess they are now defunct and mostly lost.


User avatar
bwinkel67
QL Wafer Drive
Posts: 1196
Joined: Thu Oct 03, 2019 2:09 am

Re: ZX81 BASIC

Post by bwinkel67 »

I was playing with the EightyOne emulators Spectrum 48K option and it looks like that Speccy BASIC got rid of the AT command for PRINT. Am I missing something? The did add the @ symbol so maybe you say PRINT @ 1,1;"HELLO" or something like that...I tried it and it failed.

Plus, the PLOT command now only prints a pixel instead of 4x4 pixel area. I was trying to see if it was like the QL's plot and had an additional set of arguments but it wouldn't work. Any Speccy BASIC programmers out there?


User avatar
bwinkel67
QL Wafer Drive
Posts: 1196
Joined: Thu Oct 03, 2019 2:09 am

Re: ZX81 BASIC

Post by bwinkel67 »

One general question to all QL BASIC programmers. Which should take precedence here, a variable that shares the same name as a function or the function when there is a clash? On the ZX81 this is avoided because functions are not typed in and parsed, they are dealt with by hitting a key combination and appear one way to the user but are stored another way. In a traditional parser when you parse CODE for instance, you then have to figure out what it is. I currently have the function take precedence over the variable so if I wanted to define the variable CODE then likely it would take a backseat to the function CODE.


Post Reply