sz81 emulator

Emulator and emulator development specific topics
zx4ever
Posts: 18
Joined: Wed Jun 27, 2018 10:58 pm

Re: sz81 emulator

Post by zx4ever »

Exile wrote: Mon Jan 08, 2024 1:35 pm So the key thing seems to be to find the p directory that sz81 creates and put renamed p files within it. Here's a quick screenshot showing some of the files...
sz81.jpg

This is quite an old version of sz81, so it will have issues with hi-res programs.
This is great, thank you very much. :)
I also noticed that it's an older version, but I'm new to the Risc OS world and don't have the knowledge to compile myself.
Here is the sz81 github page, maybe someone can help with compiling latest version.
https://github.com/SegHaxx/sz81
User avatar
mrtinb
Posts: 1911
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: sz81 emulator

Post by mrtinb »

I thought the SZ81's homepage was here: https://www.weggetjes.nl/sz81/
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
zx4ever
Posts: 18
Joined: Wed Jun 27, 2018 10:58 pm

Re: sz81 emulator

Post by zx4ever »

mrtinb wrote: Mon Jan 08, 2024 3:32 pm I thought the SZ81's homepage was here: https://www.weggetjes.nl/sz81/
Yes, you are right, this is the home page, obviously there are more places, with source code.

edit:
It seems that this version from the home page is the latest, about the same as the one from the github page, from two years ago.
Exile
Posts: 45
Joined: Tue Jan 03, 2023 9:50 pm

Re: sz81 emulator

Post by Exile »

I invested a few hours and tried to compile 2.3.12 on RiscOs using gcc 4 which can be installed on RiscOS.

After some hacking, mainly due to RiscOs using . as a directory marker, I got it running to the K prompt. However, it did not last long on a Pi2 as it used all the CPU, starving the OS. I checked the CPU usage of the 2.1.7 port, and that took 90%, so I should not have been surprised.

I recompiled on a Pi4 and did get it to display menus and run a program, but it was not a good experience, with the OS crashing on several occasions.

By this point the joy of running a collaboratively multitasking OS that only used 1 of the 4 cores on my Pi was losing its appeal. It reminded me of Windows 3.1 :-)

It could have been the way I built it. People may get more joy cross compiling, and possibly targeting the later ARM CPUs. In any event, I think I'll leave any future work on getting the latest sz81 running on RiscOS to someone else. Of course, sz81 does run extremely well on a Pi, if the Pi is running Raspberry Pi OS ;)
zx4ever
Posts: 18
Joined: Wed Jun 27, 2018 10:58 pm

Re: sz81 emulator

Post by zx4ever »

Exile wrote: Thu Jan 11, 2024 9:31 pm I invested a few hours and tried to compile 2.3.12 on RiscOs using gcc 4 which can be installed on RiscOS.

After some hacking, mainly due to RiscOs using . as a directory marker, I got it running to the K prompt. However, it did not last long on a Pi2 as it used all the CPU, starving the OS. I checked the CPU usage of the 2.1.7 port, and that took 90%, so I should not have been surprised.

I recompiled on a Pi4 and did get it to display menus and run a program, but it was not a good experience, with the OS crashing on several occasions.

By this point the joy of running a collaboratively multitasking OS that only used 1 of the 4 cores on my Pi was losing its appeal. It reminded me of Windows 3.1 :-)

It could have been the way I built it. People may get more joy cross compiling, and possibly targeting the later ARM CPUs. In any event, I think I'll leave any future work on getting the latest sz81 running on RiscOS to someone else. Of course, sz81 does run extremely well on a Pi, if the Pi is running Raspberry Pi OS ;)
Thank you for your effort and feedback.
Can you share the download link for the pi2 version?
I would like to try it on my overclocked pi3 to see how usable it is.
I'm not expecting too much, just curious. ;)
Exile
Posts: 45
Joined: Tue Jan 03, 2023 9:50 pm

Re: sz81 emulator

Post by Exile »

Good news!

After some more study of the ins and outs of RiscOS I've built and run sz81 2.3.12. Hi-res, sound, UDG and chroma all seem to be working at the right speed on a Pi4 running RiscOS.

The build is also stable on a Pi2, but runs at less than full speed. Setting a higher frameskip helps. @zx4ever reports that it runs at the correct speed on their overclocked Pi3b+

Some Notes:
1. The program crashes on closing. This appears to be an issue in the RiscOS SDL implementation, and also occurs with the 2.1.7 build created a few years ago. However, unlike the 2.1.7 built, this version does manage to save the settings to the rcfile before crashing ;-)
2. sz81 assumes that it has a local current working directory. If you multi-task whilst using sz81 you may notice the cwd changing for other RiscOS apps.
3. For the full retro effect, press F11 to go fullscreen
4. Optimisation at O3 has been used for the time sensitive code, some SDL load and save code crashes if optimised above O1, so they are left at O1. Some changes were made to the pointer manipulation in sld_main.c update_scrn, so that it could run successfully at O3

I've attached a zip created using RiscOS.

Update [2]:
Further improvements have been made, see viewtopic.php?p=54029#p54029. The file originally attached to this post has been deleted, the linked post linked contains zips of more recent versions
Last edited by Exile on Sun Jan 28, 2024 10:20 pm, edited 2 times in total.
zx4ever
Posts: 18
Joined: Wed Jun 27, 2018 10:58 pm

Re: sz81 emulator

Post by zx4ever »

Exile wrote: Sat Jan 13, 2024 1:33 pm
I tried on both Pi2B v1.1 and Pi3A+ but it refuses to work.
Clean install of RiscOS 5.28, emulator unpacked and started, but complains with this message.
Image

After I changed the file type to App (Absolute), as in the initial version, I got an attempt to start, but this time with a warning that something could go wrong and after "Continue" nothing happens.
The debug screen shows this on pi2 and a very similar message with &00009064 error on pi3.
Image
Don't know whats going on and why it doesn't work at least on the pi2.
I read all your notes, just didn't understand part 2, but if you have any hint how to make it work for me, please help.
Thanks.
Exile
Posts: 45
Joined: Tue Jan 03, 2023 9:50 pm

Re: sz81 emulator

Post by Exile »

I've built the executable as an ELF file, which is the default when using gcc. It appears RiscOS cannot load those file types without an ELF loader. I did try to use ELF2AIF, but that failed as I've dynamically linked in libraries. It looks like it all works for me, as I had installed an ELF loader.

I'll see if I can get a build that is accepted by ELF2AIF, but in the meantime, can you try going into PackMan and installing SharedLibs? The description for that says it includes an ELF loader, so I guess that is where mine came from :-)

You should then be able to change the sz81 file type back to ELF and (fingers crossed) it should run.

Let me know how you get on, to avoid extending the thread too much perhaps we can move to private messages until we have a solution? :-)
Exile
Posts: 45
Joined: Tue Jan 03, 2023 9:50 pm

Re: sz81 emulator

Post by Exile »

I've now rebuilt to use the AIF executable format. zx4ever reports that it installs and runs at the right speed on a Pi3b+. I have installed it on a clean Risc OS installation, and it ran "out of the box". I've also increased the optimisation level of the compile where possible, but a Pi2 still struggles to run it at 100% with no frameskips.

The post above, where I first uploaded the executable has been edited and a new zip file has replaced the original. My apologies if you had already downloaded the first version.

A good check for whether there is enough CPU speed to run sz81 appears to be to enable sound. If the CPU struggles sound buffers get corrupted, and faint noise can be heard when no .p file is running.
Exile
Posts: 45
Joined: Tue Jan 03, 2023 9:50 pm

Re: sz81 emulator

Post by Exile »

With the help of some very thorough testing by zx4ever we now have 3 version of sz81 for Risc OS that have been run on Raspberry Pis. They are attached.

sz81o
Based on sz81 2.1.8 UI, with the core emulation loop ported back from picozx81, this is a lightweight version that runs on a Pi2. It has good hi-res and sound emulation, but does not support Chroma. It supports loading and saving of memory blocks, but not a full ZXPand+. To enable low memory, select a memory size of 24, 40 or 56kB. WRX and UDG graphics (CHR16 and QS) are supported. There are command line options to support NTSC vsync rates and larger display windows (described in the git Readme.)
The code is at https://github.com/ikjordan/sz81_2_1_8
Scripts and instructions to build in Risc OS are included

sz81n
Based on 2.3.12. Supports Hi-res, sound and Chroma. A small change has been made to ensure the ROM is protected when loading memory blocks (the abba music player splash screen was loading the bitmap header into the end of ROM and corrupting part of the character set).
This version is significantly more processor intensive compared to sz81o. The SDL display routines have been tuned, so the whole emulator now runs approx. 30% faster than initial builds. This allows it to run at 100% on a Pi3b+ in most circumstances, but it can still sometimes struggle when playing sound with a large window size.

sz81p
Based on 2.3.12, compiled with ZXPand+ support.

The code for the 2.3.12 versions, with build instructions for Risc OS, can be found at: https://github.com/ikjordan/sz81

All Risc OS specific code changes are protected by #ifdef PLATFORM_RISCOS blocks, so they can be merged back if and when a 2.3.13 release of sz81 is created.

Improvements over the Risc OS version previously posted in this thread
1. All versions now support the reading and writing of .p files without the need to create extra directories. Files appear in Risc OS as /p files (e.g. gal.p goes to gal/p). This means that program files can be downloaded directly in Risc OS and they will run unaltered
2. All versions now shut down cleanly
3. They run significantly faster than previously uploaded versions

Pi4
The Pi4 has enough CPU to run all of the emulators at full speed. However, in testing we did find cases where the sound lagged, even though the processor is not fully loaded. I have seen a theory proposed on a Risc OS forum that this may be because the clock scaler does not take background SDL sound and timer threads into account and, thinking the machine is idle, reduces the CPU clock speed.
Attachments
RiscOSsz81n.zip
(753.37 KiB) Downloaded 49 times
RiscOSsz81z.zip
(764.53 KiB) Downloaded 46 times
RiscOSsz81o.zip
(669.61 KiB) Downloaded 37 times
Post Reply