AY emulation testing

Struggling with Fuse or trying to find an emulator with a specific feature. Ask your questions here.
User avatar
Ast A. Moore
Manic Miner
Posts: 689
Joined: Mon Nov 13, 2017 3:16 pm

Re: AY emulation testing

Post by Ast A. Moore » Thu Oct 11, 2018 5:10 pm

Pegaz wrote:
Thu Oct 11, 2018 4:13 pm
For most emulators I have tried with noise.tap file, the noise goes from silent to louder in several visible steps.
Only SpecEmu and Spin have a smooth noise transition but it looks like the sound level is the same from the beginning to the end.
Which of these two cases is closer to the real hardware?
The amplitude should remain more or less the same. This is from my Toast Rack:

Image
0 x
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.

User avatar
djnzx48
Microbot
Posts: 177
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: AY emulation testing

Post by djnzx48 » Thu Oct 11, 2018 8:58 pm

Thanks for the Spectramine links @druellan and @hikoki.

Dunno why Fuse was different when I tested it but it still sounded fine IMO. Turning the filter on still affects the sound quite a lot.

I wonder what the best solution to this is for new releases, as the difference between the two noise generators can be very noticeable in some cases. Of course it would be really nice if the emulators could be fixed, but the workaround for doubling noise periods doesn't actually sound too bad. The clunky part would be having to stick in a menu option for it and getting the user to pick the right one.
0 x

User avatar
Ast A. Moore
Manic Miner
Posts: 689
Joined: Mon Nov 13, 2017 3:16 pm

Re: AY emulation testing

Post by Ast A. Moore » Thu Oct 11, 2018 11:23 pm

djnzx48 wrote:
Thu Oct 11, 2018 8:58 pm
The clunky part would be having to stick in a menu option for it and getting the user to pick the right one.
Yeah, that would be a bad thing to do.

Unfortunately, in this day and age of a gazillion of emulators, developers are faced with a choice—to code for the Spectrum or to code for a particular emulator. I chose the former, and, frankly, couldn’t give a rat’s behind about how emulators handle my code. That’s why I feel completely justified in calling myself a Spectrum developer.

Now, I’m way past the age of coming down hard on people who decide to tailor their code to a specific emulator—software or hardware (e.g. the various clones of the Spectrum, both old and new)—it’s their choice. I may curmudgeonly mutter something along the lines of “And they dare call themselves Spectrum developers?” but only under my breath, and mostly in jest. At the same time, if I’m in the right mood, I’ll happily point out that something in their code doesn’t work quite right on a real Spectrum. :D

The purist in me would suggest refining your code so that it behaves the way you want it to on real hardware and forget about tweaking it to work the same way in an emulator.

That said, Fuse with the “TV speaker” filter on sounds pretty darned close to the real thing to my ear (and by “the real thing” I mean an actual Spectrum hooked up to an actual TV—a CRT one, to boot). So, I’d say—stick with that setting. ;)
1 x
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.

User avatar
djnzx48
Microbot
Posts: 177
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: AY emulation testing

Post by djnzx48 » Fri Oct 12, 2018 2:04 am

Yeah, I agree that targeting the actual machine is preferable. The reality is though that not everyone owns real Spectrums, and many people are forced to use emulators as their only option. Personally I'd like to write programs for platforms that people will run them on, and I'd say Spin, SpecEmu and Spectaculator together probably make up the majority of emulators in use, without considering clones.

Even if you ignore emulators you still have to deal with compatibility issues, such as the contended memory banks being different on the +2A/+3. I know emulators aren't official Spectrum models, but they're in wide use so it's reasonable to want to support them.

And it's not just a binary decision. You can develop for the Spectrum primarily but still have emulation/additional hardware in mind, for example with ULAplus.
1 x

User avatar
Fred
Berk
Posts: 37
Joined: Tue Feb 27, 2018 3:15 am

Re: AY emulation testing

Post by Fred » Fri Oct 12, 2018 6:11 am

Ast A. Moore wrote:
Thu Oct 11, 2018 5:10 pm
Pegaz wrote:
Thu Oct 11, 2018 4:13 pm
For most emulators I have tried with noise.tap file, the noise goes from silent to louder in several visible steps.
Only SpecEmu and Spin have a smooth noise transition but it looks like the sound level is the same from the beginning to the end.
Which of these two cases is closer to the real hardware?
The amplitude should remain more or less the same. This is from my Toast Rack:
This would be caused by filtering on those frequencies - you can see the difference in Fuse when you turn filtering on and off.
Fuse manual wrote: This option allows the emulation of the sound output system to be modified. Different choices of speaker limit the bass and treble response that can be produced from the machine. Choose between a “TV” type speaker and a small beeper type speaker that significantly limits bass and treble response or Unfiltered for the full frequency range like from the MIC output.
0 x

User avatar
Pegaz
Microbot
Posts: 150
Joined: Mon Nov 13, 2017 1:44 pm

Re: AY emulation testing

Post by Pegaz » Fri Oct 12, 2018 10:10 am

djnzx48 wrote:
Fri Oct 12, 2018 2:04 am
Yeah, I agree that targeting the actual machine is preferable. The reality is though that not everyone owns real Spectrums, and many people are forced to use emulators as their only option. Personally I'd like to write programs for platforms that people will run them on, and I'd say Spin, SpecEmu and Spectaculator together probably make up the majority of emulators in use, without considering clones.

Even if you ignore emulators you still have to deal with compatibility issues, such as the contended memory banks being different on the +2A/+3. I know emulators aren't official Spectrum models, but they're in wide use so it's reasonable to want to support them.

And it's not just a binary decision. You can develop for the Spectrum primarily but still have emulation/additional hardware in mind, for example with ULAplus.
I completely agree.
Emulators are very important and the best of them already behave practically as real Spectrum.
Their benefits will be even greater in the future, as there will be less and less working Spectrum around.
For me, every Spectrum is equally important , whether its based on emulator, fpga or some other non-original hardware.
Otherwise, even Amstrad models might not be considered as original hardware too.
With the emulators, Spectrum will drastically extend its life span and user base, without them it will only become just a piece of hardware in the museum.
0 x

User avatar
Ast A. Moore
Manic Miner
Posts: 689
Joined: Mon Nov 13, 2017 3:16 pm

Re: AY emulation testing

Post by Ast A. Moore » Fri Oct 12, 2018 1:25 pm

djnzx48 wrote:
Fri Oct 12, 2018 2:04 am
Yeah, I agree that targeting the actual machine is preferable. The reality is though that not everyone owns real Spectrums, and many people are forced to use emulators as their only option. Personally I'd like to write programs for platforms that people will run them on, and I'd say Spin, SpecEmu and Spectaculator together probably make up the majority of emulators in use, without considering clones.

Even if you ignore emulators you still have to deal with compatibility issues, such as the contended memory banks being different on the +2A/+3. I know emulators aren't official Spectrum models, but they're in wide use so it's reasonable to want to support them.

And it's not just a binary decision. You can develop for the Spectrum primarily but still have emulation/additional hardware in mind, for example with ULAplus.
Sure. Perhaps, I didn’t express myself clearly. I didn’t mean to say you should go out of your way to write software that will only work properly on real hardware. Quite the opposite, in my book, it would be a mistake to go out of your way to write software that will only work properly on a particular emulator, even if it happens to be the most popular emulator.

Yes, it’s difficult enough to create workarounds for all the models of the real Spectrum. Aside from RAM contention differences, here are a few other quirks of the real hardware:

1. 48/16K Spectrums display colors differently from all the subsequent iterations. Darker colors exhibit smaller differences between their bright and non-bright variations (e.g. bright blue and non-bright blue look virtually identical). I’m not aware of any emulator that ever attempted to implement this behavior.

Image

2. The 48K/128K/+2 Spectrums are affected by something commonly referred to as the ULA snow effect, if the I registered is pointed to a particular range of values and the CPU is accessing contended memory. Some emulators can reproduce this effect to a certain degree of accuracy. None (that I know of), reproduce it 100 percent correctly. Many, simply ignore this quirk altogether. Note: At least one Spectrum game—Vectron (1985)—used it deliberately as a special effect.

3. Timing differences between all three Spectrum architectures—48K/128K/+2A. These have been mostly accurately implemented in many emulators, especially those that are being actively maintained.

4. Reading from certain ports (e.g. any port with Bits 1 and 15 reset) will cause the 128K/+2 machines to reset/hang. Some emulators don’t implement this behavior, or implement it incorrectly.

5. The floating bus behaves differently on the +2A/+3 than it does on other models. Since we’ve extensively studied and fully described its behavior in late 2017, only SpecEmu and Spectramine have correctly implemented it.

6. Issues 1 and 2 of the Spectrum 48K return different values when port $FE is read from. This causes some games that use simplified (and incorrect) keyboard polling routines to not work on later Spectrum models. Some emulators do offer an option to enable this behavior, but not all.

7. The Z80 has its own set of quirks, and not all emulators implement its behavior accurately.

8. No emulator is, of course, capable of displaying the Spectrum output at its native 50 fps. This isn’t the fault of any particular emulator, naturally, but rather the systems they runs on: most modern computers are locked to a 60 Hz refresh rate.

The above is by no means an exhaustive list, by the way.

So, given than no emulator implements all the quirks of the real hardware 100 percent correctly, how do you find the lowest common denominator? Do you just drop features or implement workarounds so that your game runs okay on the oldest and buggiest emulator? Do you think emulator authors will be incentivized to implement any of the missing features or fix the existing bugs if developers try to go out of their way to work around the emulators’ shortcomings?

I don’t know exactly when the first Spectrum emulator was written, but I think it’s a safe bet to say it was some time in the 1990s. People have had over a quarter of a century to figure out how to accurately emulate a very inexpensive and fairly simple 8-bit computer form the 1980s. How come no-one has done it yet? I don’t know the exact answer to that question (but am aware of the technical hurdles), yet I’m pretty sure it’s partly due to the complacency of Spectrum developers. Because regular gamers are rarely very demanding. The colors are slightly off? Who cares . . . The sound isn’t quite right? Who cares . . . The timing is not super accurate? Who cares . . . As long as I can run Manic Miner or Jet Pac . . .

Now, by no means do I dismiss the efforts of emulator authors. I fully understand that it’s a tremendous task in and of itself, especially if you don’t have access to real hardware or the knowhow of reverse engineering it. I myself primarily use emulators for development and most of the testing, and only use real hardware for final testing and fine tuning. But I don’t cut features or abandon techniques or otherwise compromise my code to cater to the shortcomings of a particular emulator. Nor do I add features that will only work in a particular emulator, unless they also work on real hardware.

That’s my philosophy in a nutshell.
Pegaz wrote:
Fri Oct 12, 2018 10:10 am
Emulators are very important and the best of them already behave practically as real Spectrum.
Their benefits will be even greater in the future, as there will be less and less working Spectrum around.
For me, every Spectrum is equally important , whether its based on emulator, fpga or some other non-original hardware.
Otherwise, even Amstrad models might not be considered as original hardware too.
With the emulators, Spectrum will drastically extend its life span and user base, without them it will only become just a piece of hardware in the museum.
Yes, but what do those emulators actually emulate? The Spectrum or the emulator author’s idea of what the Spectrum should have been like? I’m all for the preservation of the Spectrum. (I doubt many people will share our passion to the same degree it after our generation finally kicks the bucket, though.) But let’s preserve the actual Spectrum, to the best of our abilities. While the actual machines still run and while the people who understand, or can figure out, how they work are still around.

I’m not an activist at heart, but I do feel like we need to form a lobby to persuade emulator authors to try to make an effort and work on improving the emulation, rather than adding features to their oeuvres. However, I know what most of them will say (and I completely understand them): “We’re just doing this for fun. We’re not working for you. We don’t get paid for this, anyway, and simply spend our free time to do the things we love. If you want your bloody ‘super-accurate emulation,’ do it yourself.”

A man can dream, though. A man can dream . . .
1 x
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.

User avatar
Ersh
Microbot
Posts: 127
Joined: Mon Nov 13, 2017 1:06 pm

Re: AY emulation testing

Post by Ersh » Fri Oct 12, 2018 2:12 pm

Ast A. Moore wrote:
Fri Oct 12, 2018 1:25 pm
8. No emulator is, of course, capable of displaying the Spectrum output at its native 50 fps. This isn’t the fault of any particular emulator, naturally, but rather the systems they runs on: most modern computers are locked to a 60 Hz refresh rate.
Most, if not all, PC emulators support 50hz, and I'd say most screens support that refresh-rate as well. I have a cheap ASUS a couple of years old and it handles 50hz just fine.

Though handhelds (maybe laptops as well?) with a dedicated screen tend to use 60hz, so for an example, on Android you're out of luck. That's what I really like about ZXDS for the Nintendo DS, it's a portable with a solid 50fps thanks to some clever code and use of the hardware.
0 x

User avatar
ZXDunny
Dizzy
Posts: 80
Joined: Tue Nov 14, 2017 3:45 pm

Re: AY emulation testing

Post by ZXDunny » Fri Oct 12, 2018 4:10 pm

Emulator authors (or at least Woody and I, when we were developing SpecEMU and ZXSpin) worked to the best available information at the time. That is to say, we implemented and tested what was known about the Speccy, but only what we could actually get. I'm sure we all remember RamSoft and their utter refusal to release any usable information about the ULA.

That they largely got it wrong was not discovered for many years after, but even so...

We had access to a +2a and a 48k model, which we would run tests on to make sure we matched it. We updated the emulators whenever we learned something new. But until Chris Smith released his ULA book, we were really working in the dark. Coming up with test programs to see what happened when certain conditions were met, that sort of thing.

One of those was the ULA Snow. Did you know that you can use that particular quirk of the hardware to do hardware-based attribute scrolling? We found that by accident. We determined roughly what it did, and how, and implemented that. But to implement it correctly would have required CPU usage in a Windows machine that was pretty much at the limit of hardware available at the time, if not more - this was back in the days well before 1GHz was commonly in use. We'd need to emulate the CPU and ULA/Display at 1 T-State accuracy which massively blew out the time spent emulating - for a feature that one or two games used.

We ended up with a "good enough" solution that allowed us to continue with 4Ts accuracy. hey, we didn't emulate memory refresh fading either, so that's on us too.

Because we were trying to emulate a Spectrum. Not some "idea of what a Spectrum was" but the actual hardware. I'm sorry if that wasn't good enough, but we did our best at the time.
2 x

User avatar
Ast A. Moore
Manic Miner
Posts: 689
Joined: Mon Nov 13, 2017 3:16 pm

Re: AY emulation testing

Post by Ast A. Moore » Fri Oct 12, 2018 7:51 pm

ZXDunny wrote:
Fri Oct 12, 2018 4:10 pm
Emulator authors (or at least Woody and I, when we were developing SpecEMU and ZXSpin) worked to the best available information at the time.
Thank you! That was a very enlightening post.

I do want to emphasize (again) that in no way do I try to take a jab at emulator authors. Moreover, and I’ve stated it on several occasions, I’m immensely grateful to Mark for implementing the floating bus on the +2A/+3. I was very excited when he came on board during our investigation of the issue and was able to come up with a new build of SpecEmu pretty soon after we’d figured out the last details. I was only too happy to create a special version of my main test program (and called it Woody’s Special) to help him fine tune his emulator, and—sure enough—his very next build replicated the behavior of the +2A dead on!

The point I’m making is that no matter how you slice it, we Spectrum software developers and you Spectrum emulator authors are in many ways co-dependent. If, as was suggested in this thread, we decide to implement workarounds—or worse, drop features—in order to fit the bill of the existing emulators, progress will never happen.

What other incentive could their be for an emulator author? Sure, some people need no external motivation (to a degree). Mark implemented the floating bus not because I'd written a game that used it, but because he just found it interesting or even exciting (I think).

Strangely enough, even Cesar, the person who actually discovered the existence of the floating bus on the +2A was not interested in pursuing it further. And he’s a bloody emulator author. :) When I started my own investigation, I tagged him a couple of times in my thread, he wasn’t all that interest and said he was busy with other things (in ZEsarUX, mind!). I get that: when he first brought it up in early 2016, the response was underwhelming, to put it mildly. My only regret is that I hadn’t returned to the scene at that time, and only discovered his post a year or more later. If I approached other emulator authors about it, they too would probably say, “Great story, bro. Ping me when there are a couple dozen more games that use it. Then I’ll think about it.”

It is, thus, a vicious circle: Spectrum developers try to avoid using certain features and quirks of the original hardware because emulators don’t support them, and emulator authors don’t implement them because there isn’t enough software that uses them. The question is: how do we get out of this rut?
0 x
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.

Post Reply