It is currently Mon Oct 23, 2017 12:09 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Sun Dec 11, 2016 7:56 pm 
Offline

Joined: Sun Dec 11, 2016 7:18 pm
Posts: 3
It may seem rather ignorant of me to ask this, but I've been composing music for a game of mine in Famitracker. I've been hoping that I could somehow get this music into my game (an FDS game) by using Famitracker's 'export ASM' feature.

What I ask is if it would be possible to just copy the resulting ASM code into the codebase for my project. If not, what is the feature's intended purpose, and finally, would there be an other way to get the music into my game?


Top
 Profile  
 
PostPosted: Sun Dec 11, 2016 8:28 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
The methodology I know of is that you export your song as an NSF, and then examine the NSF itself to see what the init + load + play addresses are, then refer to those in your code (equates work wonders). Rachel Simone Weil did exactly that in her computers-are-easy project: https://github.com/hxlnt/computers-are-easy/ (see source/ and loveiskind.asm)

What's missing from all of this is that FamiTracker uses a specific area of RAM (and likely ZP) for its player internals. I can't remember what those locations/regions are, but I'm sure someone else here knows. It's not mentioned in the .chm file or on their wiki page, and it's pretty important, so that the rest of your program/game doesn't end up conflicting.


Top
 Profile  
 
PostPosted: Sun Dec 11, 2016 8:45 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5735
Location: Canada
koitsu wrote:
What's missing from all of this is that FamiTracker uses a specific area of RAM (and likely ZP) for its player internals. I can't remember what those locations/regions are, but I'm sure someone else here knows.

No, it doesn't. It's all relocatable. (Unless you mean trying to use the NSF export, which isn't really what I'd recommend.)

You need the ASM export + the NSF driver (a separate download). There's some documentation with the NSF driver source.

The most notable problem with this is that it doesn't support sound effects. You'll need to write something else on top of that.

The most popular alternative is Shiru's Famitone (available here), which supports a subset of Famitracker features (you have to compose around this), and is designed for use in games. There are some other free / open source engines floating around as well if you want to search.


Last edited by rainwarrior on Sun Dec 11, 2016 8:48 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sun Dec 11, 2016 8:47 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1787
Location: DIGDUG
I've made a demo using famitracker's asm code/data export.

There is 2 issues, for use with a game. 1. Sound effects. You could use a bit of Shiru's famitone code, to do just sound effects, but it won't be easy.
2.the asm might not be the syntax of your preferred assembler.

Tepples seems to think that all of famitracker (including asm driver) is covered by GPL license... requiring open source for derivitive projects. I'm not a lawyer, so I don't know for sure. It may be an issue, if you have to modify the asm source code.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sun Dec 11, 2016 8:52 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5735
Location: Canada
dougeff wrote:
Tepples seems to think that all of famitracker (including asm export) is covered by GPL license... requiring open source for derivitive projects. I'm not a lawyer, so I don't know for sure. It may be an issue, if you have to modify the asm source code.

The Famitracker program is GPL, but not the NSF driver.

The NSF driver source currently has no explicit license, but from what I remember jsr has said in the past that he didn't want to encumber it with a license, and wasn't really satisfied by any existing boilerplate licenses, so it's more or less "do what you want with this". (You should contact him for clarification if you have a legal concern about it, though, rather than relying on my hearsay.)

Here is one of his comments about it from a few years ago:
http://famitracker.com/forum/posts.php?id=4337

There's some interesting related comments in the source, apparently: http://forums.famitracker.com/viewtopic.php?t=2638


Last edited by rainwarrior on Sun Dec 11, 2016 9:16 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sun Dec 11, 2016 8:59 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
rainwarrior wrote:
koitsu wrote:
What's missing from all of this is that FamiTracker uses a specific area of RAM (and likely ZP) for its player internals. I can't remember what those locations/regions are, but I'm sure someone else here knows.

No, it doesn't. It's all relocatable. (Unless you mean trying to use the NSF export, which isn't really what I'd recommend.)

Yes, that is exactly what I was referring to (hence what I wrote in my preceding paragraph). Up until now (re: the rest of your post), that was the only option I was aware was available (exporting the NSF and referring to it directly in a project). I even launched FamiTracker and looked for other options. If there's a third-party or "extension" that provides additional stuff (no offense intended), I can't really be blamed for not knowing that -- it's not natively part of FamiTracker as of this writing.

Not your fault in the least, but it's a bit of a disappointment the documentation that comes with it -- both the .chm and their wiki page (which is almost barren) -- doesn't mention this type of thing.


Top
 Profile  
 
PostPosted: Sun Dec 11, 2016 9:05 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5735
Location: Canada
It's found in the NSF export where it says "type of file". There's not much documentation of it, but it's under "NSF Exporting" in the CHM.

The Wiki content was not made by jsr, just hosted by him; it was basically just a place for some users of the Famitracker forums to collect information and ideas. I don't think people who contributed to the wiki really were interested in the ASM export. Very few people are, really.

By the way, BIN export is just as good as ASM export unless you need to modify the output in some way. A very long time ago I wrote a short guide for using it:
http://famitracker.com/forum/posts.php?id=3681

As for available music engines, I've started a list on the wiki, please contribute:
http://wiki.nesdev.com/w/index.php/Tools#Engines


Top
 Profile  
 
PostPosted: Sun Dec 11, 2016 10:11 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
rainwarrior wrote:
It's found in the NSF export where it says "type of file".

No wonder I've never seen this before: from a UI perspective, "Export NSF..." for exporting a text .asm is a bit misleading, particularly when compounded with the fact that there's File -> Export text... Yeah, I can see now how this utility is mainly catering to people who just want to make music and less so for "making music that's to be used in a NES game" (I'm being a bit harsh here, but you get what I'm saying I hope).

This is mainly me just doing a brain dump (CollisionDetection might find some sympathy in this): I'm also confused about what it outputs -- it looks like relevant NSF header, sequencer, and sample data... but where's the actual sequencer/music driver? Oh wait, I see, it's implied under the "BIN" section of the .chm: "Stores only the music data and DPCM samples in separate files, for use with the NSF driver sources which are available from the web page." But the "ASM" section isn't as clear: "Stores the music data and samples in text format that can be used with the driver sources (for CA65). More flexible than the BIN option." This refers to the "NSF driver source" download/.zip on the website, which contains the actual ca65 .s files that make up the actual sound driver. Okay, so let's look at that.

The readme.txt in there goes over some of the necessary details, but no where near what I'd hope for general use in one's own NES game/program. The ability to relocate what regions of ZP and RAM are used is in the nsf.cfg file -- person had best have familiarity with ld65. But this didn't answer my question as far as how much memory it actually used for those regions (again: conflicts between your own code and what the NSF driver uses). So I took a look at that.

The details are actually in driver.s, specifically the bits that refer to both the ZEROPAGE and BSS (RAM) segments.

It looks like about 27 bytes of ZP are used (subtract 2 if you don't need FDS support, and subtract 4 more if you don't need VRC7).

RAM-wise, it's justifiably more hefty -- I can't easily calculate it just by looking at the code (lots of .ifdefs for different features, and things that rely on equates which are ifdef'd too), but I'm sure if I was to assemble + link with ld65's --mapfile flag I'd get an accurate number. Just from skimming I'd say it uses a couple hundred bytes minimum. This is the kind of stuff people who want to use it in their projects need to know -- it'd be a rude awakening otherwise, I think.

rainwarrior wrote:
The Wiki content was not made by jsr, just hosted by him; it was basically just a place for some users of the Famitracker forums to collect information and ideas. I don't think people who contributed to the wiki really were interested in the ASM export. Very few people are, really.

Ahhh, that explains it. Thanks for the insight!

rainwarrior wrote:
By the way, BIN export is just as good as ASM export unless you need to modify the output in some way. A very long time ago I wrote a short guide for using it:
http://famitracker.com/forum/posts.php?id=3681

Perfect. I'm going to add a link directly to that under http://wiki.nesdev.com/w/index.php/Programming_guide section Tutorials / "Music, how to make, to play, sound fx". This is the first time I've seen your guide. Thank you for that!

rainwarrior wrote:
As for available music engines, I've started a list on the wiki, please contribute:
http://wiki.nesdev.com/w/index.php/Tools#Engines

Unrelated to this thread, but we need to merge the stuff from here http://wiki.nesdev.com/w/index.php/Music_tools into there, then figure out how to do a Wiki redirect so that old Music_tools links go to Tools#Music_tools. That Music_tools wiki page I found on the wiki here http://wiki.nesdev.com/w/index.php/Programming_guide under General Reference, "Music: Expansion audio, tools". I'll take care of this.


Top
 Profile  
 
PostPosted: Sun Dec 11, 2016 11:00 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5735
Location: Canada
koitsu wrote:
Yeah, I can see now how this utility is mainly catering to people who just want to make music and less so for "making music that's to be used in a NES game"

Well, as far as I know the number of people who have used it in a game is still zero.

I can't tell you what to expect, but if you're complaining that this isn't the easiest thing to use in a game, well, yes, it isn't, and nobody actually uses it for that.

You could use it for that, and under the right conditions it might even be appropriate to do so. For example, if you had a lot of pre-existing Famitracker music that was important to the project, and recomposing it for Famitone's subset of features wasn't an option, etc. There's lots of situations where it'd actually be perfectly fine to use. (I used it in my MOON8 project, for example.)

koitsu wrote:
This is mainly me just doing a brain dump...

Okay, but if there's something you'd like to see improved about it, generally the best place to make suggestions/request is at Famitracker's forums:
http://forums.famitracker.com/

Like, I can answer questions about it if I know something (I've used it a lot, inside and out), but it's not my project or anything, other than I contributed a text import/export feature to it at one point.

koitsu wrote:
The ability to relocate what regions of ZP and RAM are used is in the nsf.cfg file -- person had best have familiarity with ld65.

No, it has nothing to do with that config file. They are simply reservations made in the standard ZEROPAGE and BSS segments. They will end up wherever there is appropriate space in these segments in your own project. You would not normally use nsf.cfg for this.

(Famitone, on the other hand, uses semi-hard coded addresses, and the non-ZP block must be aligned to the start of a page. It's less relocatable than Famitracker's reservations, though still relocatable.)

koitsu wrote:
RAM-wise, it's justifiably more hefty...

The readme for Famitone2 has some RAM / cycles comparisons between itself and Famitracker if you're looking for that information.

koitsu wrote:
rainwarrior wrote:
By the way, BIN export is just as good as ASM export unless you need to modify the output in some way. A very long time ago I wrote a short guide for using it:
http://famitracker.com/forum/posts.php?id=3681

Perfect. I'm going to add a link directly to that under http://wiki.nesdev.com/w/index.php/Programming_guide section Tutorials / "Music, how to make, to play, sound fx". This is the first time I've seen your guide. Thank you for that!

Please test it first. It's from several years and several Famitracker versions ago. (Also it's a link to the old forum, which is not editable, etc. so I can't field questions there either. I was offering the link as interest to the OP's question, not as a submission for archival material.)


Top
 Profile  
 
PostPosted: Fri Dec 16, 2016 11:41 pm 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3471
Location: Indianapolis
Just thought I'd mention that Shiru recently posted an example of using the Famitracker driver with Famitone's sound effects. If you don't want to deal with the optimizing your music for Famitone.
http://shiru.untergrund.net/files/src/cc65_neslib_famitracker.zip
http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=169473


Top
 Profile  
 
PostPosted: Tue Dec 20, 2016 7:38 pm 
Offline

Joined: Sun Dec 11, 2016 7:18 pm
Posts: 3
With all that said, would it be possible to just write a new sound driver altogether?


Top
 Profile  
 
PostPosted: Tue Dec 20, 2016 7:44 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10067
Location: Rio de Janeiro - Brazil
Of course.


Top
 Profile  
 
PostPosted: Tue Dec 20, 2016 7:46 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19120
Location: NE Indiana, USA (NTSC)
Yes. The complexity of writing a new music engine depends on what effects you want to support.

Do you heavily use portamento (FamiTracker effects 1, 2, 3, Q, and R)? If not, or if portamento can be replaced with grace notes, I have to toot my own horn and recommend Pently.


Top
 Profile  
 
PostPosted: Tue Dec 20, 2016 8:05 pm 
Offline

Joined: Sun Dec 11, 2016 7:18 pm
Posts: 3
Would anyone have suggestions as to where I could read about how to write a sound engine?


Top
 Profile  
 
PostPosted: Tue Dec 20, 2016 8:48 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1787
Location: DIGDUG
You can look at the source code of actual games. SMB has been fully disassembled.

Also, these...
http://www.romhacking.net/?page=documen ... csearch=Go

And you can see the source code for Pently, famitone2, and famitracker. Oh, and...I think Gradual Games.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: DRW, lidnariq and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group