Skip to content

Commit

Permalink
Fix DPCM segment start address in nonbankswitching
Browse files Browse the repository at this point in the history
  • Loading branch information
Gumball2415 committed Jun 21, 2024
1 parent fa05bd9 commit 8a3ee83
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion Source/ChunkRenderText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,14 @@ void CChunkRenderText::StoreNSFConfig(unsigned int DPCMSegment, stNSFHeader Head
}
else {
str.Append(" CODE: load = PRG, type = " + segmentType + ";\n");
str.AppendFormat((" DPCM: load = PRG, type = " + segmentType + ", start = $%04X;\n"), DPCMSegment);
str.Append(" DPCM: load = PRG, type = " + segmentType);
// this is tricky. the driver size is unpredictable here.
// so instead, we only start at address DPCMSegment
// *only if* the nonbankswitching DPCM segment address remains at CCompiler::PAGE_SAMPLES
if (DPCMSegment == CCompiler::PAGE_SAMPLES)
str.AppendFormat(", start = $%04X;\n", DPCMSegment);
else
str.Append(";\n");
}

str.Append("}\nFILES {\n # hack to get .dbg symbols to align with code\n %O: format = bin;\n \"%O_header\": format = bin;\n}");
Expand Down
6 changes: 3 additions & 3 deletions Source/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ void CCompiler::ExportBIN(LPCTSTR lpszBIN_File, LPCTSTR lpszDPCM_File, int Machi
bool bCompressedMode;
unsigned short MusicDataAddress;

CalculateLoadAddresses(MusicDataAddress, bCompressedMode);
CalculateLoadAddresses(MusicDataAddress, bCompressedMode, true);

// Init is located first at the driver
m_iInitAddress = m_iDriverAddress; // !! !!
Expand Down Expand Up @@ -1143,7 +1143,7 @@ void CCompiler::ExportASM(LPCTSTR lpszFileName, int MachineType, bool ExtraData)
bool bCompressedMode;
unsigned short MusicDataAddress;

CalculateLoadAddresses(MusicDataAddress, bCompressedMode);
CalculateLoadAddresses(MusicDataAddress, bCompressedMode, true);

stNSFHeader Header;
CreateHeader(&Header, MachineType, 0x00, false);
Expand Down Expand Up @@ -1998,7 +1998,7 @@ bool CCompiler::CompileData(bool bUseNSFDRV, bool bUseAllExp)
// Get samples start address
m_iSampleStart = m_iNSFDRVSize + m_iDriverSize + m_iMusicDataSize;

// Align to closet 64-byte page after $C000
// Align to closest 64-byte page after $C000
if (m_iSampleStart < 0x4000)
m_iSampleStart = PAGE_SAMPLES;
else
Expand Down

0 comments on commit 8a3ee83

Please sign in to comment.