Creating NSF from scratch problems

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

Post Reply
User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Creating NSF from scratch problems

Post by oRBIT2002 »

I'm having issues with creating an NSF from my friends music (and I'm an nsf-newbie). Neither Mesen or WinAmp plugin will play it so probably have done something wrong.
I'm pretty sure the header is correct but I am a bit uncertain about the init/play-functionality.
The play-functionality is called at regular intervals by the NSF-driver and I don't need to handle that myself?

The start of my NSF sort of looks like this, init/load address is $8000 and playaddress is $8003
.ORG 8000,0
Init: Jmp InitMusic
Play: Jmp PlayMusic
<rest of the code>

The "PlayMusic" is usually called from the NMI...
User avatar
Ben Boldt
Posts: 1149
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: Creating NSF from scratch problems

Post by Ben Boldt »

What do you mean by “from scratch”? Is the source material from an existing NES game, or are you planning to take a music score or audio recording and manually create an NSF from it by hand? If it’s the latter, you could use famitracker both to write the music and generate your NSF, and then not even deal with the details of NSF format.
User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Re: Creating NSF from scratch problems

Post by oRBIT2002 »

I have the source code + data for some music but it isn’t in nsf-format. It is hand coded and not from any tracker.
User avatar
Ben Boldt
Posts: 1149
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: Creating NSF from scratch problems

Post by Ben Boldt »

You basically want to rip an NSF from an existing ROM file that already plays correctly in an emulator? And you are saying that you have the benefit of also having the source code?

Is there any reason you don’t want to share the files with us? Maybe we can review it and point out the errors.
User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Re: Creating NSF from scratch problems

Post by oRBIT2002 »

Here's my little experiment..

Here's the NSF-header:

Code: Select all

Header:
		dc.b "NESM"
		dc.b $1A
		dc.b	1				;Version
		dc.b	1
		dc.b	1
		dc.w	$8000			;Load address
		dc.w	$8000			;Init
		dc.w	$8003			;Play
		dc.b	"Storm                          ",0
		dc.b    "Fredrik 'Wizard' Schultz       ",0
		dc.b    "                               ",0
		dc.b	$1A,$41			;Speed
		dc.b	0,0,0,0,0,0,0,0	;Bankswitch
		dc.w	0				;PALSpeed
		dc.b	0				;NTSC-tune
		dc.b	0				;No extra chips
		dc.b	0,0,0,0			;Expansion

And the NSF itself (well, sort of), player is in another file..

Code: Select all

			PROCESSOR 6502
			.ORG 8000,0
			include "include/Constants.asm"

InitMusicX:	jmp Init		;$8000
PlayMusicX:	jmp PlayMusic	;$8003
	
Init:			lda #64
			sta OS_REGION
			jmp InitMusic

			include "include/os.asm"
			include "include/stormplayer.asm"

			.ORG $C000,0
Sample:   	 incbin "sfx/sample.dmc"      
User avatar
Ben Boldt
Posts: 1149
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: Creating NSF from scratch problems

Post by Ben Boldt »

I am still not completely clear what you are trying to do. Do you have an existing NES file that already plays? If you post (or PM me) your compiled NES file that does play, and you compiled NSF file that doesn't play, I will take a look at them and see if I can find the error.
User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Re: Creating NSF from scratch problems

Post by oRBIT2002 »

I have a musicreplayer (asm-source) complete with a song (asm-source aswell) that I want to "convert" to an NSF-file.
User avatar
Ben Boldt
Posts: 1149
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: Creating NSF from scratch problems

Post by Ben Boldt »

Does your music replayer + song run in an emulator when you compile it? Or does that not work either?

I haven’t played with NSFs in a while so I don’t immediately know what could be wrong. If you post a non-working, compiled NSF file, I can help debug it, which can then point us to what you did wrong in the source code.
User avatar
oRBIT2002
Posts: 687
Joined: Sun Mar 19, 2006 3:06 am
Location: Gothenburg/Sweden

Re: Creating NSF from scratch problems

Post by oRBIT2002 »

I got it working actually. Rearranged my sourcefiles a bit and then it just worked. Some type of compilation-problem...
I attach the result if anyone's interested.
Attachments
Storm.nsf
(2.19 KiB) Downloaded 55 times
Post Reply