Page 2 of 2

Posted: Thu Dec 03, 2009 6:34 pm
by MottZilla
So you're designing the functionality of this mass storage device and leaving it up to anyone who would design a hardware version to determine what medium to use and make sure it works with your API? Obviously write access wouldn't work with certain mediums and audio tracks couldn't be played while accessing data on certain mediums. Would this just have to be something the developer of a program taking advantage of this would have to be aware of?

It would be neat to see multiple incarnations of mass storage devices using the same API and being able to play the same homebrew creations, even with some differing capabilities.

So would this design mean that there would be no DMA from mass storage to memory on A-BUS? And with Flash or CD-ROM would you just be writing something like a sector number or block number you want to read or possibly write?

I'm just curious how it would function from the point of view of the SNES programmer.

Posted: Thu Dec 03, 2009 9:10 pm
by Near
I envision the first version to be as cheap as possible:
- CD-ROM unit for playing music, output to 3.5mm and mix via audio splitter. Our device would just be a proxy for sending playback commands to it. Like a remote control.
- SD card or flash chip for streaming ROM data.
- separate power source or leech off the SNES, either way.
- don't include an actual CD drive with the system, just the connector and an empty slot.
- build it with veroboard if we have to.
So you're designing the functionality of this mass storage device and leaving it up to anyone who would design a hardware version to determine what medium to use and make sure it works with your API?
The capabilities will be based on the version number, and the version number will be based on what we can actually do with the hardware itself.

In other words, the first emulator release will be as restrictive as possible: no writing, one audio track only, seek delays and a max 512MB range. Once a hardware device actually exists, we'll see what it can do. If it can write, then we'll still use version 1, but allow it to write and update the emulator to match the hardware. If not, we leave it at that.

If someone comes along in the future who simply must have write capability, then he can add it and produce new hardware using a new medium, and we can call that version 2. That will still be fully compatible with version 1 hardware.

Although ideally I don't want more than one version of hardware, I'll leave it open for the sake of creating an actual device.
It would be neat to see multiple incarnations of mass storage devices using the same API and being able to play the same homebrew creations, even with some differing capabilities.
Indeed that is a possibility. I would be more happy though if the different mediums shared the same capabilities, the only differences being that SD would probably have lower latencies for getting the data and audio streams ready.
So would this design mean that there would be no DMA from mass storage to memory on A-BUS? And with Flash or CD-ROM would you just be writing something like a sector number or block number you want to read or possibly write?
You would have to stream DMA to WRAM. Set a fixed-mode transfer from $21f1 to $7e8000+, and dump your data there. Now you can move it to video or whatever. It's annoying doing it twice to get data to video RAM, but because you're otherwise idle during active display, there's way more than enough time for even smkdan's video example.

Again I don't like it, but avoiding it would rule out the possibility of a base unit device, and subsequently of CD-ROM as a storage medium in a non-hideously-ugly form.

As for how it writes, that's up to the device and if we even support writing. It would probably require the SD controller to look up a file inside an FAT32 file system and then use byte positions inside of it. Or perhaps we can just write to the raw sectors and make a special SD formatting tool to get images on there. Whatever's cheaper.

Posted: Thu Dec 03, 2009 10:06 pm
by MottZilla
Sounds good to me. And it would seem that if this base unit is created it would be possible if you wanted to make your own little BIOS cartridge that lets you run your own program from within WRAM very easily for fun. I do like the idea of using a CD-ROM personally. Seems like it shouldn't be that hard to do either since Bung managed to do basically what we are talking about already.

Posted: Sun Dec 06, 2009 6:04 am
by Near
Okay, for those who want to play around, I've added 21fx support to the latest WIP.

http://byuu.org/temp/bsnes_v057_wip05.tar.bz2
(if the link is dead, you took too long to get it, sorry.)

You will need the DLLs from the official version to run it. It also leaves the debugger enabled and lacks profile optimizations so it's even slower than normal.

Here's an example 21fx ROM + source:
http://byuu.org/temp/21fx.tar.bz2

It looks for 21fx.bin in the game path. If it finds it, it enables 21fx support. It won't work with SuperFX, SA-1 or Super Game Boy, at least not yet; because they all need the coprocessor thread to run.

It will read four bytes in from 21fx.bin (skipping the first byte to show seeking capability) and write it to save RAM. This specific "game" also tries to play audio00000.wav. I didn't include it because those files are big. Use Winamp DiskWriter or something and create a 44.1KHz, 16-bit stereo, signed, PCM uncompressed WAV file. Put it in the same folder as the game and it'll play. Save states work on it as well.

Interface:

Code: Select all

$21f0 = command port
Write:
00 = set data port address (parameter port[0-5] = offset)
01 = set audio track# (parameter port[0-1] = track#; also serves as a stop command)
02 = set volume (parameter port[0] = left volume, parameter port[1] = right volume)
03 = play / pause current track
Read:
d7 = data port ready (wait before reading data port)
d6 = audio track ready (wait before issuing play command)
d5 = audio playing flag (use this to auto-repeat the song if desired)
d4 = audio paused flag
d3-d0 = version (for capabilities and chip detection)

$21f1 = data port
Write: reserved for now, will still increment address
Read: fetches data, increments address

$21f2-7 = parameter ports 0-5
Read: returns current data port address
Absolutely none of this is set in stone. I'm leaving the version code at zero to emphasize this. Use it at your own risk, but if you do, please let me know how it goes. I'm very interested to see what we can do with this.

I haven't added any actual delays yet, so be sure to use the wait flags. Once the API is official, I'll probably add a ~1ms seek delay to both.

Posted: Sun Dec 06, 2009 1:23 pm
by MottZilla
I've got some ideas I'll have to attempt.

Posted: Sun Dec 06, 2009 2:00 pm
by Near
Cool. smkdan said he was successful already in getting Super Mario World to play back MP3->WAV files instead of BGM. Meaning sound effects would still work.

It may be harder in some games to mute only the background music, but I believe for the most part it won't be that bad.

Also, be careful with the API, as it will change. Write a wrapper if you have to. Otherwise, only use it if you're willing to update whatever you use for v058 official.

Posted: Sun Dec 06, 2009 5:23 pm
by MottZilla
That's similar to what I'm doing as a test, attempting to add a full audio soundtrack to a game which requires telling the game not to play the music. I've made progress on the particular game I'm trying this on but still have things to figure out. Also just a minor question, why no ability to play an audio track with a "Repeat" setting? Or is there but I missed it. Otherwise you have to hack games to constantly poll if music has stopped playing.

Posted: Sun Dec 06, 2009 5:53 pm
by Near
That's what I was discussing on my forum. We're going to merge the parameter registers into a shift register, and update play/pause to be more explicit on what you want to do (play with or without repeat, or pause).

For now, it'll just loop the wave file. But eventually I'm thinking we should include a "seek back location" inside the wave file for clean looping without fading.

-----

EDIT: new build, just go to my page to read the new info and spec. Don't feel like copy and pasting. I think this API is 99% final now, and it has a repeat command.

Posted: Mon Dec 14, 2009 4:34 am
by tomaitheous
I just wanted to say, this sound like a great idea. I just hope it makes it into production - even if in small amounts. That way it's not consider "fantasy" emulation ;)

Posted: Mon Dec 14, 2009 5:37 am
by Near
If you or anyone could help, we'd really appreciate it :)

Current issue: we need a 28-pin (though it can be 56-pin and we ignore every other one) edgeboard connector. It needs to look exactly like this:
http://img410.imageshack.us/img410/4654/dsc00587id.jpg

1.25in or 3.175cm wide, with pin spacing of 1mm pin to 1mm gap = 2mm per.

Posted: Mon Dec 14, 2009 4:38 pm
by caitsith2
byuu wrote:If you or anyone could help, we'd really appreciate it :)

Current issue: we need a 28-pin (though it can be 56-pin and we ignore every other one) edgeboard connector. It needs to look exactly like this:
http://img410.imageshack.us/img410/4654/dsc00587id.jpg

1.25in or 3.175cm wide, with pin spacing of 1mm pin to 1mm gap = 2mm per.
That should be 1.25in x 0.32in (or 3.175cm x 0.813cm), due to physical constraints of the snes side of the connection.
Width of 0.32in or 0.813cm

The card edge itself is 1.12in x 0.072in (or 2.831cm x 0.183cm)

Posted: Mon Dec 14, 2009 5:11 pm
by Near
caitsith2 wrote:The card edge itself is 1.12in x 0.072in (or 2.831cm x 0.183cm)
You mean the inner portion of the card edge from the SNES side?

Thanks for measuring that with the caliper, by the way.