Gens4All with Z80 Emulation

Place for discussing homebrew games, development, new releases and emulation.
dcsteve
lithium
Posts: 37

Re: Gens4All with Z80 Emulation

Post by dcsteve »

TapamN wrote:I looked into the clicking sounds I mentioned before, and it seems to be an issue with SDL. I dumped the raw data sent to SDL and played it back with Audacity, and there wasn't any clicking. So the issue seems to be with SDL. I thankfully won't have to try to debug the sound emulation. I tried replacing SDL with KOS streaming functions, but they don't seem usable. I had trouble getting them to work. Looking through the source for it, the implementation seems to require (but doesn't mention in the documentation) a buffer greater than 2048 samples, or about 1/10th of a second at 22KHz, for the streaming to work. I had the buffer set to about 1/50th of a second, and the streaming library thought that there wasn't enough to bother loading more samples. That minimum buffer size is way too big to be usable for an emulator. My next goal is getting a lower latency streaming replacement to work, without clicking.
Blackaura solved the clicking noise in his port of genesis plus for dreamcast. Here is the source if it provides any information to help you compare sound code.

https://www.zophar.net/download_file/172

TapamN
drunken sailor
Posts: 160

Re: Gens4All with Z80 Emulation

Post by TapamN »

dcsteve wrote:Blackaura solved the clicking noise in his port of genesis plus for dreamcast. Here is the source if it provides any information to help you compare sound code.
Somehow I never knew that emulator existed. Huh.

It looks like they took the KOS streaming code and cut it down a bit and used that. I was going to try something like that. It didn't seem to have the issue with requiring a giant minimum latency, so I tried to add it to Gens4All. It took a while, but when I finally got it working correctly... it had the exact same clicking in PS2 (and some other games) as SDL.

If the software is fine, maybe the problem is hardware? I looked through the hardware setting code, and I noticed that the loop end was set to the length of the loop. That seems odd for the hardware to be designed like that. It should be easier to check that the loop triggers after the current than checking head one sample. I changed the loop end to be buffer_length - 1, and tried it.

The clicking was gone.

So it looks like the AICA doesn't start the loop before hitting the loop end value, it starts the loop after playing sample at the loop end. The clicking on the left channel was from a single sample from the right channel buffer being played.

The non-looping sample end register might also work this way, but I haven't checked.

I noticed there was slightly more CPU usage with Genesis Plus's streamer than when using SDL. The streamer used spu_memload, while SDL didn't. I tried replacing spu_memload with a modified version of SDL's loader, but it didn't improve it. I'm not total sure where the speed difference is from. Maybe it's because of having more buffers to deal with? (With SDL, emu reads stereo two buffers, writes one interleaved stereo for SDL, then SDL reads one. With GP's streams, the emu reads stereo two buffers, writes two separated stereo for the streamer, then the streamer reads those two. So it might be more cache misses?) It's probably worth coming back to sound later to get rid of the intermediate sound buffer and just write samples more directly to the AICA. For now, I'm using the version of SDL that Ian posted with the loop point setting fixed.

I wasn't planning to work on a ROM loader right away, but I changed my mind and added a basic file browser. No settings or sorting. A precompiled ELF is included in the attachment with current source. It can read from /cd and /pc. Loading large directories over BBA is really slow. I don't know about CDs.

I had some trouble getting it to where you could exit one game and load another without the sound stopping or it freezing. I tried going back to the original Gens4All source to see what I had changed that was causing it to have issues with the sound. Oh right, this version didn't have sound originally... I think I was able to get it to switch reliably.

Enter a directory or start a game with A. To go up a directory, press B. To exit the loader, press start. To exit a game and return to the loader, press ABXY+Start.
Attachments
gens4all with loader.7z
(1.59 MiB) Downloaded 362 times

dcsteve
lithium
Posts: 37

Re: Gens4All with Z80 Emulation

Post by dcsteve »

Just tested this build out. Far superior sound compared to all other emulators. Every other emulator has a slight sound to video delay and strange intermittant sound effect cracks which your build doesnt. No sync issues and superior sound quality. Amazing work.

User avatar
Ian Micheal
Developer
Posts: 6277
Location: USA
Contact:

Re: Gens4All with Z80 Emulation

Post by Ian Micheal »

Yeah with the other sound code in gens+ your doing more memory copy hence puting more load every memory copy saved = speed

So yes more buffers and copying will make more load take cpu time
Sdl i gave you has a saving in that

User avatar
soniccd123
dark night
Posts: 63

Re: Gens4All with Z80 Emulation

Post by soniccd123 »

Amazing emulator, been testing for sometime. The speed and sound quality is incredible!

User avatar
Ian Micheal
Developer
Posts: 6277
Location: USA
Contact:

Re: Gens4All with Z80 Emulation

Post by Ian Micheal »

soniccd123 wrote:Amazing emulator, been testing for sometime. The speed and sound quality is incredible!
this version been out less then week

User avatar
soniccd123
dark night
Posts: 63

Re: Gens4All with Z80 Emulation

Post by soniccd123 »

Ian Micheal wrote:
soniccd123 wrote:Amazing emulator, been testing for sometime. The speed and sound quality is incredible!
this version been out less then week
I know, with sometime I mean this week lol, maybe i need to change the wording in my post

kremiso
Rank 9
Posts: 966

Re: Gens4All with Z80 Emulation

Post by kremiso »

Bump, this deserve more views imo
an improved Megadrive emulator with better sound :!:

for who have not noticed yet, the latest upload contain also the plain files, to make your own tests/collection 8-)

User avatar
FlorreW
DC-Talk Addict
Posts: 509
Dreamcast Games you play Online: Quake 3 sometimes

Re: Gens4All with Z80 Emulation

Post by FlorreW »

kremiso wrote:Bump, this deserve more views imo
an improved Megadrive emulator with better sound :!:

for who have not noticed yet, the latest upload contain also the plain files, to make your own tests/collection 8-)
Awesome , gonna test some of the must have games <3

dcsteve
lithium
Posts: 37

Re: Gens4All with Z80 Emulation

Post by dcsteve »

Hope someone puts together a CDI full of roms for this. Its by far the best genesis emulator for dreamcast yet. Hopefully Tap can make the same improvements to snes4all one day.

  • Similar Topics
    Replies
    Views
    Last post