ZXSimulator for the Sinclair QL

Emulator and emulator development specific topics
bwinkel67
Posts: 60
Joined: Mon Mar 23, 2020 2:38 am

Re: ZXSimulator for the Sinclair QL

Post by bwinkel67 »

dr beep wrote:
Tue Apr 07, 2020 10:18 pm
My ZX81 emulator uses another way since I didn’t have so much memory on a ZX Spectrum. This is slower but still is the quickest way on a ZX Spectrum. Same routine is used on Galaksija-emulator for the SAM Coupe.
Which one is your ZX81 emulator? Sorry if that's a dumb question. I'm newer to the ZX81/Spectrum community and haven't used many (other than EightyOne and it's online version). I'm more of a QL'er and this ZXSimulator project was just to see if I could do it on an 1983 128K machine. But I find the whole ZX81 emulation (and Spectrum) fascinating because they are on a whole different level than some of the other emulators as they have to manage audio data in different formats to read in code...that part is a pretty cool component. For me, I'm just dealing with text files for the ZXSimulator...easy peasy.

dr beep
Posts: 1284
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: ZXSimulator for the Sinclair QL

Post by dr beep »

bwinkel67 wrote:
Wed Apr 08, 2020 11:17 pm
dr beep wrote:
Tue Apr 07, 2020 10:18 pm
My ZX81 emulator uses another way since I didn’t have so much memory on a ZX Spectrum. This is slower but still is the quickest way on a ZX Spectrum. Same routine is used on Galaksija-emulator for the SAM Coupe.
Which one is your ZX81 emulator? Sorry if that's a dumb question. I'm newer to the ZX81/Spectrum community and haven't used many (other than EightyOne and it's online version). I'm more of a QL'er and this ZXSimulator project was just to see if I could do it on an 1983 128K machine. But I find the whole ZX81 emulation (and Spectrum) fascinating because they are on a whole different level than some of the other emulators as they have to manage audio data in different formats to read in code...that part is a pretty cool component. For me, I'm just dealing with text files for the ZXSimulator...easy peasy.
This one..
https://www.worldofspectrum.org/infosee ... $&pub=^YRS$

And the SAM is further developped by another after I wrote the initial version... there is also a hires capable version somewhere from me.

bwinkel67
Posts: 60
Joined: Mon Mar 23, 2020 2:38 am

Re: ZXSimulator for the Sinclair QL

Post by bwinkel67 »

dr beep wrote:
Thu Apr 09, 2020 3:53 pm
This one..
https://www.worldofspectrum.org/infosee ... $&pub=^YRS$
So a few questions. When I go to the page there is a ZX81Emul.tap file and when I put EightyOne into ZX Specturm 48K mode I can load that in and it seems to be a tape loader program. Where is the ZX81 Emulator for the Speccy?

Also, if you are emulating the ZX81 for the Spectrum, do you have to write code for the instruction set for the Z80 since the Spectrum has an actual Z80 already built in? I'm guessing the hardware of the Speccy is sufficiently different that you have to emulate the Z80 and the constituent parts that make up the ZX81 so that machine code programs will load and run properly on the Speccy, is that right? Can ZX81 BASIC programs run sufficiently well on the Speccy without mod?

dr beep
Posts: 1284
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: ZXSimulator for the Sinclair QL

Post by dr beep »

The file starts with a convertor to alter .P into TAP.
Second program is the emulator, so just BREAK and load again.

When the K appears you can use the emulator. Press 1 and 0 for a menu.
A few games are added too. 3D Monster Maze, RED ANTS and Graffity.

As for the emulation: you can’t load on the same address as on a ZX81, so each opcode must be emulated to check if go to or read from memory. The altered address must be accessed.

On a ZX128 or a SAM you can use a different location for the screen and with hardware on a ZX128 [ROM] you can load the games on right addresses. Then you only need toupdate screen and read keyboard during intrupts.

User avatar
1024MAK
Posts: 2892
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: ZXSimulator for the Sinclair QL

Post by 1024MAK »

Although the ZX BASIC is a development of ZX81 BASIC, the ZX Spectrum can’t load ZX81 programs. And even if it could, they are sufficiently different that it causes problems.

In you type in a ZX81 program into a ZX Spectrum, most code will work, except the ZX81 specific commands are not accepted by the ZX Spectrum (SCROLL, UNPLOT, FAST or SLOW), and the syntax may be different for some commands.

Also the PLOT coordinates are different.

Mark

bwinkel67
Posts: 60
Joined: Mon Mar 23, 2020 2:38 am

Re: ZXSimulator for the Sinclair QL

Post by bwinkel67 »

dr beep wrote:
Sat Apr 11, 2020 8:32 am
The file starts with a convertor to alter .P into TAP.
Second program is the emulator, so just BREAK and load again.
Hi,

So I got it loaded and running in the EightyOne emulator under Spectrum 48K modem. EightyOne does have some weird behaviors that I'm hoping you can help me with:
  • It loads the ZX81EMUL.TAP file just fine and I'm at the "PRESS A KEY TO LOAD PROGRAMS" input. When I press a key I get nothing, have to hit space to break and RUN and again I'm at the screen and this time hitting a key moves me past that menu.
  • Now it asks at bottom "ENTER NAME, THE SAME OR ANOTHER:" and here I tried various things but finally just typed "BANNER" (after trying "BANNER.P" which is the file I'm trying to load and is sitting in the same directory as the ZX81EMUL.TAP file) and hit enter to which it says "Start tape, then press any key" but there is no way to start tape in EightyOne and if I do an "Open Tape..." from the file menu it just wants to load a new TAP file and freezes on the .P file. So I just hit enter and it takes me back to that "ENTER NAME, THE SAME OR ANOTHER:" menu and when I hit enter by itself I get "Invalid file name" and then when I do LOAD "" it looks to be starting the emulator and gets stuck after RED ANTS
  • If I skip the tape loading part and just type LOAD "" I get into the ZX81 emulator fine.
So how do I use the tape conversion program. The BANNER.P file loads and runs fine in the EightyOne ZX81 mode.

I will type in my BASIC BANNER program into your emulator directly which is my timing program for the ZXSimulator to do a time comparison of your emulator running on the Speccy 48K -- emulated in realtime by EightyOne -- I think I'm using the latest 2018 version (1.16).

bwinkel67
Posts: 60
Joined: Mon Mar 23, 2020 2:38 am

Re: ZXSimulator for the Sinclair QL

Post by bwinkel67 »

1024MAK wrote:
Sat Apr 11, 2020 12:35 pm
Also the PLOT coordinates are different.
BTW, I figured out how the ZX81 handles the PLOT coordinates. It does not use the character map for it but does try to work with the existing character map. When it is about to plot its 4x4 "pixel" into an 8x8 square it first checks each 4x4 quadrants to see if there is anything in there and it looks for all or nothing (i.e. if each quadrant is completely empty or filled it does not clear the 8x8 square but if it finds a quadrant that is partially filled it clears the entire square).

You can try this by plotting over a character and it will be cleared. If you print a graphics character and plot over one of the unused white areas it just fills it in unless the graphics character has "grey" in it, in which case it treats it like a character and clears the 8x8 square area. My current implementation doesn't do that so if I experience a character then I share the space which is not fully ZX81 PLOT compatible and looks a bit weird. But if I clear each 8x8 area when plotting I could never plot two 4x4 "pixels" in proximity of each other :-/

dr beep
Posts: 1284
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: ZXSimulator for the Sinclair QL

Post by dr beep »

bwinkel67 wrote:
Sat Apr 11, 2020 10:15 pm
So how do I use the tape conversion program. The BANNER.P file loads and runs fine in the EightyOne ZX81 mode.
The conversionprogram only runs on a real ZX Spectrum. It can load ZX81 games in 300 baud and save them as 1500 BAUD TAP-programs.

I am coding a new emulator and planning to built a converter that will run on a ZX Spectrum emulator, will load .P via BLOCK and SAVE as .TAP

Somewhere in the net is a converter that will convert .p to .tap but it might need DOSBOX

bwinkel67
Posts: 60
Joined: Mon Mar 23, 2020 2:38 am

Re: ZXSimulator for the Sinclair QL

Post by bwinkel67 »

Here's a head-to-head comparison between the ZXSimulator and the Spectrum ZX81-Emulator running the BANNER.BAS program (square pattern through normal and inverted for a full loop) with EightyOne running in 50Hz PAL mode.
  • ZXSimulator on unexpanded QL: 100 seconds 97 seconds (fixed a small bug that slowed things down)
  • ZX-81 Emulator on unexpanded Spectrum: 132 seconds
  • Actual ZX-81 50Hz PAL model: 57 seconds
Note that I'm making assumption here that the EightyOne emulator is running the Spectrum 48K in real-time. It does so for the ZX81 and I'm running it on a pretty fast laptop where I can get QLAY2 (the QL emulator) to run ZXSimulator with the BANNER.BAS test program in less than a second.

The comparison to the Speccy ZX81-Emulator is not uniform of course since the program listing on the ZXSimulator is an example where it took about a second longer. Of course most importantly the Speccy ZX81-Emulator can run machine code programs so it's not a fair comparison since the ZXSimulator lacks that all-important feature making it mostly useless for most game titles. Again, this was just a fun project to see if I could simulate the ZX81 BASIC on an unexpanded QL. But considering that at one point it was running 15 times slower I'm happy that I'm within 40% so not bad. I'm actually impressed that the ZX81-Emulator running on an unexpanded Spectrum is fully emulating the ZX81 and only running a little over twice as slow as the original ZX81 (2.3x to be exact)...that's remarkable if you think about it.

I really wanted to see how other non-Windows ZX81 emulators fared (i.e. emulators/simulators running on top of other 80's computers since that took a lot of effort to make usable and I find impressive -- I still want to try Whitby Speccy simulator for the C64 to see how fast it ran and it is more like mine since it is not an emulator).

BTW, were there speed differences between later Spectrum models -- are there faster unexpanded Speccy's out there? I assume there is no 60Hz mode like in the ZX81 since the Spectrum never made it to the US. I'll keep the EightyOne open and check since I will note retype the BANNER.BAS program as it was pretty painful using the old ZX81 keyboard mapping -- the one positive ZXSimulator attribute is that program entry is fast since you can just type the commands and not use key tokens.
Last edited by bwinkel67 on Sun Apr 12, 2020 7:39 am, edited 1 time in total.

bwinkel67
Posts: 60
Joined: Mon Mar 23, 2020 2:38 am

Re: ZXSimulator for the Sinclair QL

Post by bwinkel67 »

dr beep wrote:
Sat Apr 11, 2020 10:59 pm
I am coding a new emulator and planning to built a converter that will run on a ZX Spectrum emulator, will load .P via BLOCK and SAVE as .TAP
Oh cool...would love to play with that eventually...
dr beep wrote:
Sat Apr 11, 2020 10:59 pm
Somewhere in the net is a converter that will convert .p to .tap but it might need DOSBOX
Great, I will look for that since I have other demo programs I've written and am currently writing a simple implementation of the game Elite to see how it runs on mine. Though I love the QL I've never really gotten into writing BASIC programs in it (I do C on it instead with a C compiler that I've had since the early 90's that can run from microdrives). But there is something about the ZX81 that I find fun writing BASIC programs -- funny since it is so much more lacking but maybe that makes it fun or the fact that the graphics is so limiting.

I recently saw a some games that blew me away (non-BASIC of course): Astroids, ZX80 Kong, Glooper, Gauntlet, and my two favorites City Patrol (w/parallax effect) and My Little Ghost (with pseudo-3D effect).

Post Reply