From 941ce401938f016e96e4f53a284282e3e173dc7c Mon Sep 17 00:00:00 2001 From: qwertymodo Date: Mon, 7 Nov 2016 11:18:32 -0800 Subject: [PATCH] Clean up MSU-1 audio file derivation. --- msu1.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/msu1.cpp b/msu1.cpp index 3a8e693b..9420dc7d 100644 --- a/msu1.cpp +++ b/msu1.cpp @@ -200,7 +200,6 @@ std::ifstream dataFile, audioFile; uint32 audioLoopPos; -char fName[64]; uint32 partial_samples; // Sample buffer @@ -213,13 +212,11 @@ bool AudioOpen() if (audioFile.is_open()) audioFile.close(); - // This is an ugly hack... need to see if there's a better way to get the base name without extension - sprintf(fName, "%s", S9xGetFilename(".msu", ROMFILENAME_DIR)); - fName[strlen(fName) - 4] = '\0'; - sprintf(fName, "%s-%d.pcm", fName, MSU1.MSU1_CURRENT_TRACK); + char ext[_MAX_EXT]; + snprintf(ext, _MAX_EXT, "-%d.pcm", MSU1.MSU1_CURRENT_TRACK); audioFile.clear(); - audioFile.open(fName, std::ios::in | std::ios::binary); + audioFile.open(S9xGetFilename(ext, ROMFILENAME_DIR), std::ios::in | std::ios::binary); if (audioFile.good()) { if (audioFile.get() != 'M')