Skip to content

Commit

Permalink
Add NSF stub file for .asm export
Browse files Browse the repository at this point in the history
  • Loading branch information
Gumball2415 committed Feb 16, 2024
1 parent 72148d6 commit c694e69
Show file tree
Hide file tree
Showing 8 changed files with 202 additions and 168 deletions.
48 changes: 0 additions & 48 deletions Dn-FamiTracker.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,6 @@
<Manifest />
<Manifest />
<Manifest />
<PreBuildEvent>
<Command>call "$(ProjectDir)Source\drivers\build.cmd"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Compiling NSF driver</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ASAN-Debug|Win32'">
<Midl>
Expand Down Expand Up @@ -267,12 +261,6 @@
<Manifest />
<Manifest />
<Manifest />
<PreBuildEvent>
<Command>call "$(ProjectDir)Source\drivers\build.cmd"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Compiling NSF driver</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
Expand Down Expand Up @@ -314,12 +302,6 @@
<Manifest />
<Manifest />
<Manifest />
<PreBuildEvent>
<Command>call "$(ProjectDir)Source\drivers\build.cmd"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Compiling NSF driver</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ASAN-Debug|x64'">
<Midl>
Expand Down Expand Up @@ -361,12 +343,6 @@
<Manifest />
<Manifest />
<Manifest />
<PreBuildEvent>
<Command>call "$(ProjectDir)Source\drivers\build.cmd"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Compiling NSF driver</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Midl>
Expand Down Expand Up @@ -410,12 +386,6 @@
<DataExecutionPrevention>true</DataExecutionPrevention>
</Link>
<Manifest />
<PreBuildEvent>
<Command>call "$(ProjectDir)Source\drivers\build.cmd"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Compiling NSF driver</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ASAN-Release|Win32'">
<Midl>
Expand Down Expand Up @@ -459,12 +429,6 @@
<DataExecutionPrevention>true</DataExecutionPrevention>
</Link>
<Manifest />
<PreBuildEvent>
<Command>call "$(ProjectDir)Source\drivers\build.cmd"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Compiling NSF driver</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
Expand Down Expand Up @@ -509,12 +473,6 @@
<DataExecutionPrevention>true</DataExecutionPrevention>
</Link>
<Manifest />
<PreBuildEvent>
<Command>call "$(ProjectDir)Source\drivers\build.cmd"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Compiling NSF driver</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ASAN-Release|x64'">
<Midl>
Expand Down Expand Up @@ -559,12 +517,6 @@
<DataExecutionPrevention>true</DataExecutionPrevention>
</Link>
<Manifest />
<PreBuildEvent>
<Command>call "$(ProjectDir)Source\drivers\build.cmd"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Compiling NSF driver</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Source\APU\digital-sound-antiques\emu2413.c" />
Expand Down
12 changes: 3 additions & 9 deletions Dn-FamiTracker.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,6 @@
<ClCompile Include="Source\ConfigEmulation.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Source\JsonExporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Source\Exception.h">
Expand Down Expand Up @@ -956,6 +953,9 @@
<ClInclude Include="Source\Compiler.h">
<Filter>Header Files\Export Headers</Filter>
</ClInclude>
<ClInclude Include="Source\Driver.h">
<Filter>Header Files\Export Headers</Filter>
</ClInclude>
<ClInclude Include="Source\PatternCompiler.h">
<Filter>Header Files\Export Headers</Filter>
</ClInclude>
Expand Down Expand Up @@ -1496,12 +1496,6 @@
<ClInclude Include="Source\rigtorp\SPSCQueue.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Source\JsonExporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Source\Driver.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Dn-FamiTracker.rc">
Expand Down
2 changes: 1 addition & 1 deletion Source/ChunkRenderBinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ int CChunkRenderNSF::GetDATAChunkSize() const

void CChunkRenderNSF::StoreChunkBankswitched(const CChunk *pChunk)
{
switch (pChunk->GetType()) {
switch (pChunk->GetType()) {
case CHUNK_FRAME_LIST:
case CHUNK_FRAME:
case CHUNK_PATTERN:
Expand Down
50 changes: 39 additions & 11 deletions Source/ChunkRenderText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,21 +486,48 @@ void CChunkRenderText::WriteFileString(const CStringA &str, CFile *pFile) const

// These functions write to a separate file. CFile path to those separate files must be the same as export.

void CChunkRenderText::StoreNSFStub(stNSFHeader Header, bool Bankswitched, vibrato_t VibratoStyle, bool LinearPitch, bool IsAssembly) const
{
CString str;

str.Append(";\n; NSF stub file, used to define compile constants\n;\n\n");
if (Header.SoundChip & SNDCHIP_VRC6)
str.Append("USE_VRC6 = 1\n");
if (Header.SoundChip & SNDCHIP_VRC7)
str.Append("USE_VRC7 = 1\n");
if (Header.SoundChip & SNDCHIP_FDS)
str.Append("USE_FDS = 1\n");
if (Header.SoundChip & SNDCHIP_MMC5)
str.Append("USE_MMC5 = 1\n");
if (Header.SoundChip & SNDCHIP_N163)
str.Append("USE_N163 = 1\n");
if (Header.SoundChip & SNDCHIP_S5B)
str.Append("USE_S5B = 1\n");
if (Bankswitched)
str.Append("USE_BANKSWITCH = 1\n");
if (VibratoStyle == VIBRATO_OLD)
str.Append("USE_OLDVIBRATO = 1\n");
if (LinearPitch)
str.Append("USE_LINEARPITCH = 1\n");
str.Append("PACKAGE = 1\n");
str.Append("HAS_NSF_HEADER = 1\n");
str.Append("USE_AUX_DATA = 1\n");

if (IsAssembly)
str.Append("INC_MUSIC_ASM = 1\n");

str.Append("\n.include \"driver/driver.s\"\n;\t path to NSF driver source\n");

str.Append("\n.include \"music.asm\"\n;\t path to NSF export source\n");

WriteFileString(str, m_pFileNSFStub);
}

void CChunkRenderText::StoreNSFHeader(stNSFHeader Header) const
{
CString str;

str.Append(";\n; NSF Header\n;\n");
// TODO: make seperate stub file
//if (Header.SoundChip & SNDCHIP_VRC6) str.Append("USE_VRC6 = 1\n");
//if (Header.SoundChip & SNDCHIP_VRC7) str.Append("USE_VRC7 = 1\n");
//if (Header.SoundChip & SNDCHIP_FDS) str.Append("USE_FDS = 1\n");
//if (Header.SoundChip & SNDCHIP_MMC5) str.Append("USE_MMC5 = 1\n");
//if (Header.SoundChip & SNDCHIP_N163) str.Append("USE_N163 = 1\n");
//if (Header.SoundChip & SNDCHIP_S5B) str.Append("USE_S5B = 1\n");
//if (m_bBankSwitched) str.Append("USE_BANKSWITCH = 1\n");
//if (m_pDocument->GetVibratoStyle() == VIBRATO_OLD) str.Append("USE_OLDVIBRATO = 1\n");
//if (m_pDocument->GetLinearPitch()) str.Append("USE_LINEARPITCH = 1\n");

str.Append("\n.segment \"HEADER1\"\n");
str.AppendFormat(".byte $%02X, $%02X, $%02X, $%02X, $%02X\t; ID\n",
Expand Down Expand Up @@ -659,8 +686,9 @@ void CChunkRenderText::StoreVibrato(unsigned int *pLUTVibrato) const
WriteFileString(str, m_pFileVibrato);
}

void CChunkRenderText::SetExtraDataFiles(CFile* pFileNSFHeader, CFile* pFileNSFConfig, CFile* pFilePeriods, CFile* pFileVibrato)
void CChunkRenderText::SetExtraDataFiles(CFile *pFileNSFStub, CFile* pFileNSFHeader, CFile* pFileNSFConfig, CFile* pFilePeriods, CFile* pFileVibrato)
{
m_pFileNSFStub = pFileNSFStub;
m_pFileNSFHeader = pFileNSFHeader;
m_pFileNSFConfig = pFileNSFConfig;
m_pFilePeriods = pFilePeriods;
Expand Down
16 changes: 9 additions & 7 deletions Source/ChunkRenderText.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
class CChunkRenderText;
class CDSample; // // //

typedef void (CChunkRenderText::*renderFunc_t)(CChunk *pChunk, CFile *pFile);
typedef void (CChunkRenderText:: *renderFunc_t)(CChunk *pChunk, CFile *pFile);

struct stNSFHeader;

Expand All @@ -44,14 +44,15 @@ class CChunkRenderText
{
public:
CChunkRenderText(CFile *pFile);
void StoreChunks(const std::vector<CChunk*> &Chunks);
void StoreSamples(const std::vector<const CDSample*> &Samples);
void WriteFileString(const CStringA& str, CFile* pFile) const;
void StoreChunks(const std::vector<CChunk *> &Chunks);
void StoreSamples(const std::vector<const CDSample *> &Samples);
void WriteFileString(const CStringA &str, CFile *pFile) const;
void StoreNSFStub(stNSFHeader Header, bool Bankswitched, vibrato_t VibratoStyle, bool LinearPitch, bool IsAssembly = false) const;
void StoreNSFHeader(stNSFHeader Header) const;
void StoreNSFConfig(unsigned int DPCMSegment, stNSFHeader Header, bool Bankswitched = false) const;
void StorePeriods(unsigned int* pLUTNTSC, unsigned int* pLUTPAL, unsigned int* pLUTSaw, unsigned int* pLUTFDS, unsigned int* pLUTN163, unsigned int* pLUTVRC7) const;
void StoreVibrato(unsigned int* pLUTVibrato) const;
void SetExtraDataFiles(CFile* pFileNSFHeader, CFile* pFileNSFConfig, CFile* pFilePeriods, CFile* pFileVibrato);
void StorePeriods(unsigned int *pLUTNTSC, unsigned int *pLUTPAL, unsigned int *pLUTSaw, unsigned int *pLUTFDS, unsigned int *pLUTN163, unsigned int *pLUTVRC7) const;
void StoreVibrato(unsigned int *pLUTVibrato) const;
void SetExtraDataFiles(CFile *pFileNSFStub, CFile *pFileNSFHeader, CFile *pFileNSFConfig, CFile *pFilePeriods, CFile *pFileVibrato);

// Labels
// // // moved from CCompiler
Expand Down Expand Up @@ -116,6 +117,7 @@ class CChunkRenderText
CStringArray m_wavesStrings;

CFile *m_pFile;
CFile *m_pFileNSFStub;
CFile *m_pFileNSFHeader;
CFile *m_pFileNSFConfig;
CFile *m_pFilePeriods;
Expand Down
Loading

0 comments on commit c694e69

Please sign in to comment.