Homebrew Emulation Introducing Nintellivision - an Emulator for the DS/DSi

wavemotion

Benign Geek
OP
Member
Joined
Nov 23, 2020
Messages
914
Trophies
1
XP
7,319
Country
United States
Guys - I'm really burning out on sound... 4 days and I've made no significant progress (well... other than more CPU speed!). I feel like I'm starting to go crazy and, even worse, starting to not enjoy working on the project. I think I'll take a little break and maybe some inspiration will strike (or some sound-god will arrive on the scene and take the open source and figure out the magic needed).

I'm going to turn my attention to overlays and manuals. I'd like to get some overlays done for a bunch of games I enjoy - and hopefully I can get to the point where it looks as good as the ones from @MarioKartFan :)

1635078770760.png
 

wavemotion

Benign Geek
OP
Member
Joined
Nov 23, 2020
Messages
914
Trophies
1
XP
7,319
Country
United States
What are you having trouble with?
As previously posted...

I'm trying to get a handle on sound processing via LIBNDS.

I understand the basics... enough that my emulators have full sound... but it's far from ideal. Right now, here is my basic scheme:

I pick a sound frequency - say 15360Hz which works well because it's 256 samples per frame at NTSC 60Hz.

The emulator will emulate the sound chip for the ancient gaming system... and place samples into a circular buffer of size 256 (basically it fills the buffer every frame).

I set up TIMER2 as my sound timer:
TIMER2_DATA = TIMER_FREQ(mySoundFrequency);
TIMER2_CR = TIMER_DIV_1 | TIMER_IRQ_REQ | TIMER_ENABLE;
irqSet(IRQ_TIMER2, VsoundHandler);

This IRQ handler will move 1 sample from the 256 entry sample buffer over to a larger shared buffer between the ARM9 and ARM7 cores... this other buffer is, arbitrarily, 2048 to give me a bit of sound buffering without too much latency.

And I tell the ARM7 core to use this shared memory buffer and tell it my sound frequency of 15360.

And it all works... mostly. The sound is good but every 10-30 seconds I can hear a "zinger" ... a sound glitch that I think is related to the two CPUs either accessing the shared memory together or somehow they are not in sync. But I'm not sure... I've tried larger buffers and while that makes the 'zing' happen less frequently - but it also increases the potential sound lag. I've tried hacks like letting the ARM7 run a little faster or slower... that just produces more "zingers". The only solution I've found so far is to use the FIFO to pass a single sound sample across to the ARM7 ... this works but consumes so much CPU as to be practically useless long-term.

I'm (quite obviously!) not a sound engineer... but are there any basic tricks I could use or obvious flaws in my setup? Before anyone gets too technical, assume that I'll need this explained to me on a 5th grade level :)
 

wavemotion

Benign Geek
OP
Member
Joined
Nov 23, 2020
Messages
914
Trophies
1
XP
7,319
Country
United States
Not ready for a new build, but checked in 2.9a with yet another 2-3% across-the-board speed improvement. I've also added a new Frameskip option "AGRESSIVE" that I'd only recommend for the DS-LITE/PHAT and really only if you absolutely need the extra speed. This is basically for Intellivoice games on the older hardware. With the new AGRESSIVE frameskip option the older DS-LITE/PHAT will now play Intellivoice games... TRON SOLAR SAILOR and BOMB SQUAD will play almost perfectly with just slight dips in sound... B-17 BOMBER is close with some dips when action gets frantic. SPACE SPARTANS is the worst offender - that thing chatters like crazy when you're getting pelted with alien fire... but with the new frameskip option you can generally keep it running at 55+ FPS which makes it playable (though not ideal).

If you've got a DSi and are running in DSi-mode (133MHz), don't use AGRESSIVE frameskip It's rendering at 15FPS which is fine if you need the speed... but the DSi works best with 'Odd' frameskip or 'Off' if you want to render ever frame (note, this is not always optimal -- games like D1K only draw the barrels on odd frames so showing every frame will actually show the barrels flickering which is how it would render on a TV but it's cleaner to show odd frames on that one).
 

wavemotion

Benign Geek
OP
Member
Joined
Nov 23, 2020
Messages
914
Trophies
1
XP
7,319
Country
United States
I always start of by stealing someone elses code. for example...

http://double.nz/nintendo_ds/sound_demo1.zip
That works great if I want to play a WAV or other pre-rendered audio buffer . I’m having trouble finding open source pass thru from the ARM9 to ARM7 where the ARM9 is pulling samples from an emulated sound processor.
 
  • Like
Reactions: banjo2

smf

Well-Known Member
Member
Joined
Feb 23, 2009
Messages
6,640
Trophies
2
XP
5,854
Country
United Kingdom
That works great if I want to play a WAV or other pre-rendered audio buffer . I’m having trouble finding open source pass thru from the ARM9 to ARM7 where the ARM9 is pulling samples from an emulated sound processor.
those ay chips aren't particularly complex, could the arm7 just generate the audio?
 

wavemotion

Benign Geek
OP
Member
Joined
Nov 23, 2020
Messages
914
Trophies
1
XP
7,319
Country
United States
those ay chips aren't particularly complex, could the arm7 just generate the audio?
Maybe! And that's close to my solution below...

OK... I may have just solved the sound issues. With minimal impact on the CPU performance. The DSi can handle it without any problems... still need to test on the DS-LITE CPU.

Instead of a large sample buffer that I fill on the ARM9 side, I have a sample buffer of 1 (well... 2 because the silly ARM7 library requires a minimum size of 1 32-bit buffer). On the ARM9 side, I put in the 1 16-bit sample (repeated... to fill 4 bytes) at my required sample rate. The ARM7 is set to run 2x frequency across that single sample buffer... Now I had tried this before but it sounded 'gritty' and the reason why was that I was using the normal ARM9 memory which is cached and so sometimes it would write the value quickly and sometimes more slowly and that was causing some samples to get dropped on the uncached ARM7 side.

But the ARM9 has shadow memory that is uncached... for the DS it's shifted up 0x00400000 bytes. And for the DSi it's shifted up 0xA000000 bytes (because the DSi has 16MB of memory so can't shadow the same as the DS). This uncached memory was the trick along with the single-sample buffer. It sounds almost as good as the 2.9 scheme but without any zingers!

Need to clean it up and test it more... but this one might finally be solved.
 
Last edited by wavemotion,

CrashMidnick

Well-Known Member
Member
Joined
Jul 22, 2015
Messages
725
Trophies
0
Age
41
XP
2,826
Country
France
OK... I may have just solved the sound issues. With minimal impact on the CPU performance. The DSi can handle it without any problems... still need to test on the DS-LITE CPU.

This is always when you're about to give up that you find a solution ! Good work.

To be honest, the sound was OK for me. When we talk about emulation on DS, it is far from perfect/accurate in general. You prove me that I was wrong.

Fingers crossed !
 

smf

Well-Known Member
Member
Joined
Feb 23, 2009
Messages
6,640
Trophies
2
XP
5,854
Country
United Kingdom
Now I had tried this before but it sounded 'gritty' and the reason why was that I was using the normal ARM9 memory which is cached and so sometimes it would write the value quickly and sometimes more slowly and that was causing some samples to get dropped on the uncached ARM7 side.
Probably running into cache coherence issues. As it's probably caching at least 32 bit, then once you read one 16bit sample then the next 16 bit value is already cached from what value was there before. Even if it gets overwritten before the program on the other side tries to read it.
 

wavemotion

Benign Geek
OP
Member
Joined
Nov 23, 2020
Messages
914
Trophies
1
XP
7,319
Country
United States
Not ready for a full build but version 2.9b is checked in ... and I think it's Zinger-Free!

Sound is as good as 2.9 and only a 1% CPU performance hit to straighten out the sound. Works for both DSi and DS-LITE/PHAT.

If this turns out to be the magic audio bullet, I’ve got 4 other Atari emulators that could use it.

I'd really appreciate it if anyone tries this build and has any observations about the sound... I'm going to take a nap :)
 
Last edited by wavemotion,

CrashMidnick

Well-Known Member
Member
Joined
Jul 22, 2015
Messages
725
Trophies
0
Age
41
XP
2,826
Country
France
Not ready for a full build but version 2.9b is checked in ... and I think it's Zinger-Free!

Sound is as good as 2.9 and only a 1% CPU performance hit to straighten out the sound. Works for both DSi and DS-LITE/PHAT.

I'd really appreciate it if anyone tries this build and has any observations about the sound... I'm going to take a nap :)

I will make some tests tomorrow evening and report back ;)
 

CrashMidnick

Well-Known Member
Member
Joined
Jul 22, 2015
Messages
725
Trophies
0
Age
41
XP
2,826
Country
France
I could not resist... Tested only on regular DS-LITE/PHAT : it seems to be zinger free :) Well done.

Games tested, general sound setting set to 14 (Excellent) :

Burger time : 60fps
Zaxxon : 60 fps
Beauty and the beast : 60 fps
Astrosmash : 60 fps

Intellivoice :

Tron SS : 58fps (drops to 50-52 sometimes, sound on average (20))

The sound has improve greatly since few versions. Good job !
 

wavemotion

Benign Geek
OP
Member
Joined
Nov 23, 2020
Messages
914
Trophies
1
XP
7,319
Country
United States
Version 3 is coming soon... sound seems fixed. I just checked in 2.9c with a global change to the way menus are handled - we now have font choices... mostly for @ts-x and anyone that finds the contrast of the green font a little lacking... you can now switch to a global white font across the board which makes things like menus and manuals a bit easier to read! This will also make global menu changes easier going forward - the streamlining and unification actually reduced the code size by about 10K.

I also added a new menu item for Global Config so you can jump right there without having to go through game-options first. With this change I also allow you to get into the main menu selection before you've loaded up a game so you can change global options if you want.
 
Last edited by wavemotion,

wavemotion

Benign Geek
OP
Member
Joined
Nov 23, 2020
Messages
914
Trophies
1
XP
7,319
Country
United States
Version 3.0 is released! https://github.com/wavemotion-dave/NINTV-DS

V3.0 : 25-Oct-2021 by wavemotion-dave
  • Sound fixed - no more zingers!
  • New global menu option for green vs white font.
  • New Aggressive frameskip to help with older DS-LITE/PHAT play.
  • Many small cleanups and improvements under the hood.

Big release - I hope everyone can switch up to this new version as soon as possible! I got back the 1-2% speed loss with the new sound engine - so performance is on par with v2.9 but the sound is finally fixed. Whew!

I continue to be hugely appreciative of the support many of you show me. A handful of you thumb most of my posts or come in with a kind word at just the right time... you're on my A-list :)

Enjoy!

1635167973479.png
 

CrashMidnick

Well-Known Member
Member
Joined
Jul 22, 2015
Messages
725
Trophies
0
Age
41
XP
2,826
Country
France
Version 3.0 is released! https://github.com/wavemotion-dave/NINTV-DS

V3.0 : 25-Oct-2021 by wavemotion-dave
  • Sound fixed - no more zingers!
  • New global menu option for green vs white font.
  • New Aggressive frameskip to help with older DS-LITE/PHAT play.
  • Many small cleanups and improvements under the hood.

Big release - I hope everyone can switch up to this new version as soon as possible! I got back the 1-2% speed loss with the new sound engine - so performance is on par with v2.9 but the sound is finally fixed. Whew!

I continue to be hugely appreciative of the support many of you show me. A handful of you thumb most of my posts or come in with a kind word at just the right time... you're on my A-list

Enjoy!

View attachment 281608

Tested aggressive FS :

Tron SS : 60fps (drops to 58 when voice speaking, sound on average (20). Even with Average sound settings, it sounds really good.

Unfortunately I cannot test DK1 and DK2 arcade as I did not buy them.

To me the only thing I see that may be added is a "recent roms" menu to avoid scrolling the romset. This is more a "childish whim" than anything else but...
 

wavemotion

Benign Geek
OP
Member
Joined
Nov 23, 2020
Messages
914
Trophies
1
XP
7,319
Country
United States
Thanks @CrashMidnick! Happy to hear that worked well for you.

A slightly older (just a couple of minor cosmetic bugs - nothing that affects gameplay) version of D1K is available for free:

http://www.intellivision.us/roms/roms.php

D1K is just the cleaned up version (and they got rid of the full title of the game for ... well, obvious reasons.

Grab STONIX while you're there - it's awesome if you like Arkanoid style games.

And I'll add 'recent roms' - I'm looking for more features to add :D
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    Psionic Roshambo @ Psionic Roshambo: @SylverReZ, Indeed lol