Gameboy Advance SID player

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Gameboy Advance SID player
by on (#180733)
YouTube video

I felt like doing some ARM assembly coding, so I decided to write a SID player for the GBA.
Porting the 6510 emulator I wrote for the SuperH-2 was pretty easy since it uses a lot of macros and the ARM and SuperH-2 have the same number of registers, but for the 6581 I had to start from scratch. It took a while to sort out all the bugs (the most serious ones anyway - it's still buggy), but now I've reached the point where it kind of works.
Re: Gameboy Advance SID player
by on (#180738)
Would the 6502-minus-decimal-mode emulator from PocketNES work as well? Or do SIDs actually use decimal mode?
Re: Gameboy Advance SID player
by on (#180739)
Sounds pretty good so far! Definitely a big improvement over the GBA SID player(s?) I heard back when GBA homebrew was still a brand new thing.

(Do I win anything for recognizing the tune? :P)
Re: Gameboy Advance SID player
by on (#180750)
Quote:
Would the 6502-minus-decimal-mode emulator from PocketNES work as well?

It would probably work. The question is if it would gain me anything. Unless PocketNES' 6502 emulator does dynamic recompilation (and does it well) I don't really see how it could be much faster than what I've already got.
Another aspect of it is that, if my measurements are to be trusted, the 6510 emulation only takes up about 6% of the GBA's CPU time. The 6581 (SID) emulation is what consumes the bulk of the time.

Revenant: you win a virtual tip of the hat.
Re: Gameboy Advance SID player
by on (#180784)
Does this use antialiasing?
Re: Gameboy Advance SID player
by on (#180785)
Nope, samples are generated at 19973 Hz without any filtering. Though, AFAIK the GBA itself resamples the audio to 32768 Hz before outputting it, and I don't know the details of how it does the resampling.
Re: Gameboy Advance SID player
by on (#180804)
Alright, I've got an actual ROM release of my SID player now: download

And here's a video of it running on my Gameboy Player + Gamecube.

I've been working on optimizing the 6581 emulation, and tried upping the sample rate 21845 Hz, but I started getting buffer underflows in some songs so I decided to keep the old sample rate (the average processing time is fairly low, it's the worst-case times that are causing the problems).
Re: Gameboy Advance SID player
by on (#180805)
Surely there's some range between 768cy and 840cy per sample?
Re: Gameboy Advance SID player
by on (#180808)
Yeah. After looking at it some more I don't think it's a performance issue though. I did some measurements on the lastest code by reading the VCOUNT register, and the worst-case numbers I got was a total of ~51% of the GBA's CPU time spent on emulating the 6510 and 6581.

I tried increasing the sample rate all the way up to 32768 Hz, and it runs just fine 8-)
Re: Gameboy Advance SID player
by on (#180827)
The source code is now available on github. I noticed that the Nag Champa tune crashes after a while (oops), so I guess I still have a bug somewhere that I'm going to have to look into.
Re: Gameboy Advance SID player
by on (#180845)
Here's a new ROM where I've fixed the bugs I mentioned in my previous post, and which generates samples at 32768 Hz.