audetto / AppleWin

Apple II emulator for Linux
GNU General Public License v2.0
47 stars 12 forks source link

ra2 core mockingboard from command line or conf file? #109

Closed skoregon closed 6 months ago

skoregon commented 1 year ago

Hi! I recently built emulationstation/retroarch using your applewin fork thanks to this script module: https://retropie.org.uk/forum/topic/33596/apple2e-applewin-libretro-scriptmodule-for-retropie

I have been looking for how I implement command line or conf file settings for the ra module. I'm especially interested in how I enable the mockingboards from the conf file or the command line. Can you please help me understand or point me to a list of command line and conf file parameters?

I also notice that the sound stutters and the frame rate seems low when run inside retroarch despite a low CPU/memory load (<10%). That though is not a applewin issue and I assume is just some configuration I need to tune so no question there. It runs fine without stutter on the same machine when run with the sa2 version.

audetto commented 1 year ago

1) the retroarch core does not handle command line 2) for sa2 you can either point to a different config file (--conf) or use -r to change any registry-like settings.

-r Configuration\\Slot\ 4.Card\ type=3

https://github.com/audetto/AppleWin/blob/master/source/Card.h#L8

3) speaker or mockingboard?

wn2000 commented 1 year ago

I'm also having sound stutter issue using the libretro core. Sound output is speaker. If I set it to mockingboard it seems to hang, the game opening screen never appears. RetroArch reports a high FPS though (>150 fps), even though I have vsync and sound sync enabled. So normally for other cores I get max 60fps but not for this core.

audetto commented 1 year ago

can you tell me which game, if it makes any difference.

wn2000 commented 1 year ago

Here's a recording of Oregon Trail. https://streamable.com/8d0mi1

audetto commented 1 year ago

I've just fixed a macroscopic issue, but for me both speakers and mockingboard play nicely.

wn2000 commented 1 year ago

I've just fixed a macroscopic issue, but for me both speakers and mockingboard play nicely.

Just tested. The speaker output in ra2 is fixed! FPS also no longer jumps to 180 and stays at 60 as expected. The mockingboard output still has problem for me. Once selected:

  1. No sound
  2. Game runs fairly slow
  3. FPS shows 150 in RetroArch

There's another issue in ra2 but I'll report separately.

wn2000 commented 1 year ago

Found a possible issue: https://github.com/audetto/AppleWin/blob/04140c33aeba8a304d6f7c0b72b578455d8f8e2c/source/linux/libwindows/dsound.cpp#L120

This might cause a false underrun as myWritePosition - myPlayPosition may become negative and get casted to a huge number.

Tested with gcc 9.4.0:

    size_t a = 1;
    size_t b = 9;
    size_t c = 10;

    // outputs 18446744073709551608
    std::cout << a - b << std::endl;
    // outputs 8
    std::cout << (a - b) % c << std::endl;
    // outputs 2
    std::cout << (c + a - b) % c << std::endl;
audetto commented 1 year ago

I don't see how that is a problem, and remember "everything" works now. Make sure you test on a "supported" os (ubuntu, fedora, pi 32 and pi 64, wsl) to be sure it is a real problem.

Attach here your ~/.applewin/applewin.conf and a link to the disk you have used.

EDIT: this is not possible.

To use the Mockingboard output you need to

1) put a mockingboard card in a slot 2) select the audio output 3) reboot

wn2000 commented 1 year ago

Well I agree that I haven't noticed anything even without the "fix". But I expect the effect of this to be subtle. It only occurs occasionally when the circular buffer wraps around, probably just for one frame once in a while.

re: Mockingboard. Thanks for the information. I did not know that a card needs to be put in a slot (never owned one haha). Will test more on that.

audetto commented 1 year ago

It actually happens constantly as the buffer is about 1 sec.

What could go wrong is that for some reason this line is not called

https://github.com/audetto/AppleWin/blob/ed3f07122e1fb16d036ceb5c670f7f049b278176/source/frontends/libretro/rdirectsound.cpp#L103

and maybe the frontend uses it to synchronise.

Put some logging, it should write constantly 1 frame worth of data (about 735 for Mockingboard, if the card is present).

The audio-video synch doc is very minimalistic https://docs.libretro.com/development/cores/developing-cores/#videoaudio-synchronization-considerations

audetto commented 1 year ago

If this is true, then I will ensure we always write 735 frames (of silence in case).

But my retroarch does not care about it and always goes at the right speed, even if I remove it completely.

audetto commented 1 year ago

And before you ask, playing speaker and mockingboard at the same time is possible but I need to mix the 2 streams.

In sa2 I open 2 devices and write each independently. Will give it a go.

audetto commented 1 year ago

With the latest commit, all synchronisation issues should have gone, regardless what configuration is chosen.

Still, in order to get mockingboard audio, the card needs to be inserted and its output selected.

I will look into merging multiple audio sources at once.

audetto commented 6 months ago

Mockingboard support is in a good state. Further effort to merge speaker and mb will go into a new issue.