Developing an emulator, help with tape WAVs?

For experts to discuss very technical stuff and newbies to ask why the Spectrum they bought off ebay doesn't work.
Post Reply
Mike Chambers
Drutt
Posts: 2
Joined: Fri Jan 18, 2019 1:45 am

Developing an emulator, help with tape WAVs?

Post by Mike Chambers »

Hi all, new here. I'm writing a Spectrum emulator, and I'm currently trying to implement the tape interface with WAV file input.

I'm returning with bit 6 of port 0xFE set if the current sample is high. I'm using value 192 as the threshold with 8-bit samples. So, if (tapebyte > 192) then the bit is set. I at least seem to be on the right path, because after issuing a LOAD "" command, I get this:

Image

So it is apparently understanding the tape data correctly.

Then after a few seconds the screen goes blank again, and the tape file gets completely inputted... but then nothing. Just a grey/white screen forever.

What am I missing here? I never actually owned a real Spectrum, so maybe I'm just doing something wrong usage-wise.

I also maybe missing some other hardware that needs to be emulated, but the system seems pretty simple from what I've been reading. I've got the video, keyboard input and port 0xFE input, as well as doing a vblank interrupt every frame. Anything else required for the basics?
User avatar
djnzx48
Manic Miner
Posts: 729
Joined: Wed Dec 06, 2017 2:13 am
Location: New Zealand

Re: Developing an emulator, help with tape WAVs?

Post by djnzx48 »

Nice work! The only thing I can think of is to look at the border colour (bits 0-2 on port $FE, but only with OUT) and see how it changes during the loading. Additionally, any even port will address the ULA, not just port $FE.
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2640
Joined: Mon Nov 13, 2017 3:16 pm

Re: Developing an emulator, help with tape WAVs?

Post by Ast A. Moore »

Mike Chambers wrote: Fri Jan 18, 2019 1:53 am the system seems pretty simple from what I've been reading.
And yet no Spectrum emulator out there can emulate it with a hundred percent accuracy. ;)

Check out this article. It talks about port 0xFE among other things.
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.
Mike Chambers
Drutt
Posts: 2
Joined: Fri Jan 18, 2019 1:45 am

Re: Developing an emulator, help with tape WAVs?

Post by Mike Chambers »

Thanks for the tips! It actually turns out my WAV files were bad! I sourced some others, and it works! :lol:

Image

Now on to sound support! I also need to come up with a catchy name for the emulator. Somehow "ZX Spectrum" seems a little uninspired.

Ast A. Moore wrote: Fri Jan 18, 2019 3:05 am And yet no Spectrum emulator out there can emulate it with a hundred percent accuracy. ;)
Not surprised! Writing a usable emulator for most retro systems is easy... getting all the little quirks right is HARD!
Ralf
Rick Dangerous
Posts: 2279
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: Developing an emulator, help with tape WAVs?

Post by Ralf »

Good luck with your emulator!

As for loading from .wav file, it can be quite complicated.
Wav is a direct sound recording, it's an exact copy of Spectrum cassette.

In real life you never had a perfect recording, there is some background noise, some sounds are a bit shorter or longer than expected and so on.

Zx Spectrum was quite tolerant in this matter, you were able to load some tapes with quite bad quality.

If you want to test your emulator in some rough conditions don't use .wav files created on PC from .tzx files. They are too good. Use recordings from real tapes. Then you can think of adding some filters to improve the sound. I remember names like Buttersworth or Chebyshev filter, they sometimes help.
User avatar
R-Tape
Site Admin
Posts: 6353
Joined: Thu Nov 09, 2017 11:46 am

Re: Developing an emulator, help with tape WAVs?

Post by R-Tape »

Mike Chambers wrote: Fri Jan 18, 2019 1:53 am Hi all, new here. I'm writing a Spectrum emulator...
Great stuff!

Can we put the pettifogging details to one side and ask: have you got a cool name in mind :mrgreen: ?
Post Reply