-
Notifications
You must be signed in to change notification settings - Fork 34
NSF Compilation
Persune edited this page Apr 9, 2026
·
1 revision
In Dn-FamiTracker, NSFs are compiled by translating the module data into binary data, before concatenating it to a compiled NSF driver. Of course, this is as complicated as it sounds. It's mostly done inside Compiler.cpp.
Nearly every format export is the same with subtle differences:
- clear log messages with
CCompiler::ClearLog() - detect if any NSFe features are used in a non-NSFe compatible format
-
CCompiler::CompileData()- if this fails, we clean up
CCompiler::Cleanup()and return - otherwise data and driver fits within 32kB, or it's
m_bBankSwitched
- if this fails, we clean up
- if it's
m_bBankSwitched:- we need to
ResolveLabelsBankswitched(); this can fail so return if we do fail - then we need to
UpdateFrameBanks() - and
UpdateSongBanks() - finally, we
EnableBankswitching()in the driver by patching some flags in the song header
- we need to
- otherwise, for nonbankswitched songs:
- we
ResolveLabels() - and we
ClearSongBanks()
- we
- finally, we deal with the rest:
- update DPCM sample pointers
UpdateSamplePointers() -
CalculateLoadAddresses()depending on what mode we're in
- update DPCM sample pointers
- load the driver identifier with
LoadNSFDRV()and driver proper withLoadDriver() - set the addresses of the song and the driver
SetDriverSongAddress() - then we write out the file, specific to the format
Each angstrom of data is stored in what's known as a Chunk.
Dn-FamiTracker - NES/Famicom sound tracker
Copyright (C) 2020-2026 D.P.C.M.
FamiTracker Copyright (C) 2005-2020 Jonathan Liss
0CC-FamiTracker Copyright (C) 2014-2018 HertzDevil