C64 SID emulation

Topics related to the API, programming discussions & questions, coding tips, bugs, etc. should go here.
CunningFellow
Posts: 1445
Joined: Mon Feb 11, 2013 8:08 am
Location: Brisbane, Australia

Re: C64 SID emulation

Post by CunningFellow »

The thing that made the SID more interesting than the AY3 and others was the analog filters built in.

All the other stuff is trivial to do and the Uzebox already does something almost identical.

The Mega644 and Mega8 are the same CPU inside. The 644 just has more resources. Plus the Uzebox is 28Mhz instead of 16Mhz.

Adding the filters would take almost all the CPU though and have nothing left for games.
User avatar
danboid
Posts: 1936
Joined: Sun Jun 14, 2020 12:14 am

Re: C64 SID emulation

Post by danboid »

That's pretty much what I expected. It would still be useful as a dedicated SID player.

sidplay2 claims to need a CPU like a P200 for good playback so we can't do a straight port of that. This sounds more doable.
User avatar
danboid
Posts: 1936
Joined: Sun Jun 14, 2020 12:14 am

Re: C64 SID emulation

Post by danboid »

It seems we might have another choice of code base for a UB SID player, the sid-arduino-lib:

https://github.com/cybernesto/sid-arduino-lib

It is based upon atmegasid so there probably isn't much difference between the two but maybe they made some tweaks when turning atmegasid into an arduino library? I have emailed the author of sid-arduino-lib to ask his opinion on which would be the better to use for the UB and if its good enough to play most SID files well, with what? I asked if he knows of any other open source SID players apart from sidplay2.

It would seem the easiest way to make a UB SID player would be to add this code to uzeamp so that it could be used to play sids as well as wav files so I was looking at the uzeamp wiki page:

http://uzebox.org/wiki/Uzeamp

The limitation that really stood out to me was that is supposedly can't handle more than 12 files. Is this a limitation of the uzeamp code or is this a limitation of FAT support on the Uzebox in general? Does the bootloader also have a 12 file / game limitation? What happens when more than 12 files are on the SD card, do no files get displayed in uzeamp or just the first 12?

If the user is only playing back sid files with uzeamp, they shouldn't need to reformat their SD card, I'd hope/expect.
User avatar
danboid
Posts: 1936
Joined: Sun Jun 14, 2020 12:14 am

Re: C64 SID emulation

Post by danboid »

I asked Uze about the Uzeamp FAT support via email and he said:

"I think it's probably both. I remember implementing just the bare minimum to stream WAV files. In fact when I made SD cards for the kits , the copy script would first copy the wave files on a freshly formatted card before anything else just so Uzeamp could pick them up. Pretty primitive but it worked! :P If you made a SID player I would just flush that old code and use FatFS or PetitFatFS. Much more complete and it supports fragmentation."
User avatar
danboid
Posts: 1936
Joined: Sun Jun 14, 2020 12:14 am

Re: C64 SID emulation

Post by danboid »

I wrote to the author of atmegasid to ask his thoughts on porting it to the Uzebox and I didn't like his response:

"In my opinion the AtmegaSid would need too much calculation power to be run in parallel with the video generation. Therefore I recommend to find another solution for sound generation."

Really? I'm pretty sure Atmegasid was written for a 16 Mhz Atmel yet the UB runs at 28 Mhz right? I suppose the only way to find out is to try it. He didn't have any tips for a lightweight, atmega friendly sid player either so I expect it doesn't exist unless its possible to port sidplay2 but I don't think the UB will be fast enough for that, based on zero proper research and testing.
CunningFellow
Posts: 1445
Joined: Mon Feb 11, 2013 8:08 am
Location: Brisbane, Australia

Re: C64 SID emulation

Post by CunningFellow »

28Mhz but 95% of its time is spent outputting the NTSC video.

Which means you have about as many FREE clock cycles as a 1.5 to 2Mhz CPU.

If you don't out put video or greatly reduce the number of scanlines you could do it.
User avatar
danboid
Posts: 1936
Joined: Sun Jun 14, 2020 12:14 am

Re: C64 SID emulation

Post by danboid »

I'd be fine with having to go without video whilst playing sids if that was the only way it could be done.
rv6502
Posts: 80
Joined: Mon Feb 11, 2019 4:27 am

Re: C64 SID emulation

Post by rv6502 »

With a custom video kernel you could probably get away with outputting a mostly-blank screen using multiple interrupts to only process the hsync/hblank signal transitions for most of the display, those could still output some single color raster bars, and put only a few status lines with actual tiles/text.

That might leave just enough CPU time to process the SID emulation while still outputting a video signal.
CunningFellow
Posts: 1445
Joined: Mon Feb 11, 2013 8:08 am
Location: Brisbane, Australia

Re: C64 SID emulation

Post by CunningFellow »

See if the video mode you already want to use implements

SetRenderingParameters();

For an example of it being used check out Chess4Uzebox

It sets the number of visible renderlines to something very small when it wants to have more CPU time for "thinking" about its next moves.
User avatar
danboid
Posts: 1936
Joined: Sun Jun 14, 2020 12:14 am

Re: C64 SID emulation

Post by danboid »

Hi Dan,

Sorry for my late response. I have no experience with the atmegasid project so I cannot tell you which one is better. I can tell you that the sid-arduino-lib does not emulate the SID filter so some tunes that make heavy use of it will sound different than expected. Maybe you can check what is the status of the filter emulation on the atmegasid, in order to make a better decision. The problem with the filter is that it was originally made by the analog part of the SID chip and it is not quite trivial to replicate this using digital filters.
Another challenge that you will have when playing SID files is that they include 6502 (6510) code in them, so most SID players are some sort of minimalistic C64 emulator. I’m not quite sure how feasible it is to add this emulation to the console but maybe it’s possible.
I wish you success!

Cheers,

cybernesto
Post Reply