Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select sound after rom start make the app crash #1

Open
foen opened this issue Jan 29, 2017 · 16 comments
Open

select sound after rom start make the app crash #1

foen opened this issue Jan 29, 2017 · 16 comments

Comments

@foen
Copy link

foen commented Jan 29, 2017

select sound after rom start make the app crash

@gdkchan
Copy link
Owner

gdkchan commented Jan 29, 2017

Can't reproduce the issue, but I can imagine that the issue is DirectSound maybe. It may be one of the following reasons:

  • You don't have Managed DirectX dlls referenced on the project
  • It's know that Managed DirectX can cause LoaderLocks so you need to disable those (only applies if you're getting a LoaderLock exception)
  • The app needs to be built as x86 to work with MDX (only applies if you get a BadImageFormatException)

The graphics can be rendered using GDI so they don't need DirectX at all, althrough you get some speedup using it on higher resolutions. I plan to switch to something like OpenTK for audio playback at some point, to make the emulator cross-platform.

@foen
Copy link
Author

foen commented Jan 30, 2017

did some more testing and its indeed a LoaderLock got some sound now 👍 awesome project will see if I can help but need to dig up snes documentations. opentk idk its vb.net anyways mabey SharpDX ? can be used in vb.net aswell

@gdkchan
Copy link
Owner

gdkchan commented Jan 31, 2017

Thanks. It's always nice to see people wanting to contribute to the project, one of the reasons I stopped working on it was because I was working on it alone and without feedback so it's easy to lose motivation. Anyway OpenTK can be used with vb.net and also does SharpDX. I prefer OpenTK cause it works on Linux with Mono too (and even Android!) I made a Android port of this emulator some time ago, the main issue was speed.

SNES docs:
General SNES info: http://problemkaputt.de/fullsnes.txt
SNES CPU info (65816): https://wiki.nesdev.com/w/images/7/76/Programmanual.pdf
SNES APU info (SPC700, very resumed): https://raw.githubusercontent.com/gilligan/snesdev/master/docs/spc700.txt
SNES S-DSP info (actual sound generator, quite detailed): http://www.pcedev.net/docs/brr/apudsp.txt

Those are the docs I used while developing the emulators, and are also the best ones I could find.
Just let me know if you want to know the current TODOs.

@foen
Copy link
Author

foen commented Jan 31, 2017

ah yeah current TODOs are nice to know. I never worked with opentk did some work with sharpdx. and liked it. I don't have any android device so I have no idea if it will work with Linux.

@gdkchan
Copy link
Owner

gdkchan commented Feb 1, 2017

It doesn't work with linux because DirectX is Microsoft technology and is only available on their products (Windows, Xbox...)

About current TODO:

  • Echo and Noise is not yet implemented on DSP. Also there's something else broken on it I think because some games just doesn't sound right.
  • Tales of Phantasia crashes. May be related to the missing DSP features, but could also be related to interrupts? I think that when a IRQ is raised when the IRQ disable flag is set on the CPU, the IRQ happens as soon the flag is cleared, but it doesn't behave this way.
    Edit: I doublechecked and the IRQ seems to be correct, so I don't think this is the issue.
  • Managed DirectX is over than 10 years old, was deprecated and have some issues, so it needs to go. Can be replaced with OpenTK or SharpDX like you suggested.
  • Sprite ordering have some bug that makes sprites show up in the wrong order (for example the cat on Chrono Trigger walks on top of the character instead of behind it).
  • PPU rendering is pretty slow and needs optimization. It runs OK on newer machines, but on older ones like mine it's below 60fps. It used to run at a bit more than 70fps here, but stuff like color math and hi-res slowed it down, but I'm sure it can run fast again with some optimizations.
  • Support for PAL region was not implemented (needs PAL timing, I think I just added enough to make PAL games boot, which is some bit on a PPU register).
  • PPU Open bus is not emulated.
  • Color math bugs (Clock Tower bathroom)
  • The ROM type know as "ExLoROM" is not supported. I think only Star Ocean uses it through, which wouldn't run anyway because it need the decompression chip emulation
  • Cart chips emulation would be nice to have (through I'm affraid of the performance issues)

Those are the core related issues I could remember. GUI also needs a lot of work but my priority is fixing core issues first.

@foen
Copy link
Author

foen commented Feb 1, 2017

thx for the ToDo's cos i only play super Mario worlds and it seems to run with 40 fps on my i7-6700 with only 24% used so it should be possible to run it faster 👍
i start reading the documentation it will take a while before i can do something to make the project beter 👎 i could mabey start on the UI. but your work is awesome !

iam starting to look into the sound system cos i hate the cracky noise.
think somethings gos wrong here Dim Sampled As Integer = RingDist(BuffAddr, CurrAddr, Input.Length)
cos when i change it to Needed it wont make a cracky noise just repeat the other thing

EDIT After reading for 2 hours i found out its not as easy as i thought it would be haha sounds seems to be tricky to emulate cos its not stable 60 fps. loads to learn

@gdkchan
Copy link
Owner

gdkchan commented Feb 1, 2017

Note that a few steps are necessary to make the emulator work on max speed. First go to My Project - Compile, click on Advanced Compile Options button and make sure that both "Remove integer overflow checks" and "Enable optimizations" are checked. Then, make sure you compile it as Release, not Debug (debug is twice as slow). Also, it runs faster when I run it outside of Visual Studio here.

Also yea I remember there was something wrong with sound playback.

@foen
Copy link
Author

foen commented Feb 1, 2017

I will try this out ! and see if it help with the sound aswell. and again nice work !

@gdkchan
Copy link
Owner

gdkchan commented Feb 2, 2017

I removed HiRes support since it was one of the things that had considerable impact on speed, and just a few games uses it (created a separate branch with the old Hi-Res code too). Let me know if it is running faster on your end now. Also I recommend using the Direct3D renderer since it is faster than GDI at 2x resolution (at 1x its the same thing here). "Color math bugs (Clock Tower bathroom)" seems to be fixed aswell.

@foen
Copy link
Author

foen commented Feb 2, 2017

after I build your last project on release without changing anything it runs on 60fps stable 👍 sound is not making this cracky noise !

after testing your old build on release it seems to work with the same fps !
only some cracky noise after you complete the first level but prob something that's not implemented
did add some youtube video to show what is going on : https://youtu.be/X7eLgVF5Ptk

@gdkchan
Copy link
Owner

gdkchan commented Feb 2, 2017

Yea, the buffer seems to get ouf os sync at this point (and the audio gets delayed later). The method I used to sync the audio buffer is not very good and produces this kind of problem after some time. I think I'll try implementing the method I used on my gba emulator later (it doesn't seem to have those sync problems, or at least is not as bad).

If you want working on that it would be a pretty nice improvement, through I think that fixing the current DirectSound based implementation is not worth, because we'll need to switch to something else (SharpDX, SlimDX, or OpenTK... Or maybe theres some other I dont know?)

The SMW sound a bit off too, so I guess theres some bug on the DSP emulation code (or maybe the missing features make that much difference?)

@foen
Copy link
Author

foen commented Feb 2, 2017

After testikg street fighter the sync issue also happen at switch of a level is like the snes dos something at that point the emulator dosnt like

@salvadorc17
Copy link

I got error when selecting directsound option, can play some games but without sound enabled.

@gdkchan
Copy link
Owner

gdkchan commented Feb 17, 2017

Which error? See my first post, may be the same error foen got.

@foen
Copy link
Author

foen commented Feb 17, 2017

Prob same crash still trying to get it in sync no huge break tru

@salvadorc17
Copy link

So which managed directx dll does this use, becuase seems all options make this crash to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants