Skip to content

Commit

Permalink
v0.71 minor fixes for some sndh replay
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-carre committed Aug 26, 2023
1 parent 799766d commit ed0f106
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 37 deletions.
2 changes: 1 addition & 1 deletion AtariAudio/AtariMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "Mk68901.h"
#include "SteDac.h"

static const uint32_t RAM_SIZE = 2*1024*1024;
static const uint32_t RAM_SIZE = 4*1024*1024;
static const uint32_t RTE_INSTRUCTION_ADDR = 0x500;
static const uint32_t RESET_INSTRUCTION_ADDR = 0x502;
static const uint32_t SNDH_UPLOAD_ADDR = 0x10000; // some SNDH can't play below (ie SynthDream2)
Expand Down
24 changes: 13 additions & 11 deletions AtariAudio/SteDac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,19 @@ int16_t SteDac::ComputeNextSample(const int8_t* atariRam, uint32_t ramSize, Mk68

while (m_innerClock >= m_hostReplayRate)
{
if (m_samplePtr == m_sampleEndPtr)
{
mfp.SetSteDacExternalEvent();
FetchSamplePtr();
if ((m_regs[0x1] & (1 << 1)) == 0)
{
// if no loop mode, switch off replay
m_regs[0x1] &= 0xfe;
m_currentDacLevel = 0;
break;
}
}

int16_t level = FetchSample(atariRam, ramSize, m_samplePtr);
if (stereo)
level += FetchSample(atariRam, ramSize, m_samplePtr + 1);
Expand All @@ -173,17 +186,6 @@ int16_t SteDac::ComputeNextSample(const int8_t* atariRam, uint32_t ramSize, Mk68
}

m_samplePtr += stereo?2:1;
if (m_samplePtr == m_sampleEndPtr)
{
mfp.SetSteDacExternalEvent();
FetchSamplePtr();
if ((m_regs[0x1] & (1 << 1)) == 0)
{
// if no loop mode, switch off replay
m_regs[0x1] &= 0xfe;
break;
}
}
m_innerClock -= m_hostReplayRate;
}
}
Expand Down
37 changes: 14 additions & 23 deletions AtariAudio/ym2149c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,8 @@ int16_t Ym2149c::dcAdjust(uint16_t v)
uint16_t Ym2149c::Tick()
{

const uint32_t envLevel = m_pCurrentEnv[m_envPos + 32];
uint32_t levels;
levels = ((m_regs[8] & 0x10) ? envLevel : m_regs[8]) << 0;
levels |= ((m_regs[9] & 0x10) ? envLevel : m_regs[9]) << 4;
levels |= ((m_regs[10] & 0x10) ? envLevel : m_regs[10]) << 8;

// three voices at same time
const uint32_t vmask = (m_toneEdges | m_toneMask) & (m_currentNoiseMask | m_noiseMask);
levels &= vmask;
m_currentDebugThreeVoices = levels;
uint32_t output = s_ymMixingVolumeTable[levels];

// update internal state
for (int v = 0; v < 3; v++)
Expand Down Expand Up @@ -180,34 +171,34 @@ uint16_t Ym2149c::Tick()
m_envCounter = 0;
}
}
return output;
return vmask;
}

// called at host replay rate ( like 48Khz )
// internally update YM chip state machine at 250Khz and average output for each host sample
int16_t Ym2149c::ComputeNextSample(uint32_t* pSampleDebugInfo)
{
#if D_DOWNSAMPLE_USE_MAX_VALUE
uint16_t tickLevel = 0;
uint32_t debugValues = 0x000;
uint16_t highMask = 0;
do
{
uint16_t level = Tick();
if (level > tickLevel)
{
tickLevel = level;
debugValues = m_currentDebugThreeVoices;
}
highMask |= Tick();
m_innerCycle += m_hostReplayRate;
}
while (m_innerCycle < m_ymClockOneEighth);
m_innerCycle -= m_ymClockOneEighth;
int16_t out = dcAdjust(tickLevel);

const uint32_t envLevel = m_pCurrentEnv[m_envPos + 32];
uint32_t levels;
levels = ((m_regs[8] & 0x10) ? envLevel : m_regs[8]) << 0;
levels |= ((m_regs[9] & 0x10) ? envLevel : m_regs[9]) << 4;
levels |= ((m_regs[10] & 0x10) ? envLevel : m_regs[10]) << 8;

levels &= highMask;
assert(levels < 0x1000);
int16_t out = dcAdjust(s_ymMixingVolumeTable[levels]);
if (pSampleDebugInfo)
{
assert(debugValues < 0x1000);
*pSampleDebugInfo = s444to888[debugValues];
}
*pSampleDebugInfo = s444to888[levels];
#else
// down-sample by averaging samples
uint16_t tickLevel;
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ATARI-ST SNDH ZIP Archive music browser/player by [Leonard/Oxygene](https://twit

# Versions

- v0.71 : minor fixes for some sndh musics
- v0.70 : un-predictable YM square tone edges as on real hardware
- v0.60 : Tao "MS3" songs support! Added subsong count in list
- v0.50 : reload last loaded SNDH archive, bug fixes for some SNDH
Expand Down
2 changes: 1 addition & 1 deletion SndhArchivePlayer/SndhArchivePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ void SndhArchivePlayer::UpdateImGui()

if (ImGui::BeginPopupModal("About", NULL, ImGuiWindowFlags_AlwaysAutoResize))
{
DrawTextCentered("SNDH Archive Player v0.70");
DrawTextCentered("SNDH Archive Player v0.71");
ImGui::Separator();
extern void OsOpenInShell(const char* path);

Expand Down
2 changes: 1 addition & 1 deletion SndhArchivePlayer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, PSTR cmdline, int cmd
//ImGui_ImplWin32_EnableDpiAwareness();
WNDCLASSEXW wc = { sizeof(wc), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, L"ImGui Example", nullptr };
::RegisterClassExW(&wc);
HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"SNDH-Archive Player v0.70", WS_OVERLAPPEDWINDOW, 100, 100, 800, 800, nullptr, nullptr, wc.hInstance, nullptr);
HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"SNDH-Archive Player v0.71", WS_OVERLAPPEDWINDOW, 100, 100, 800, 800, nullptr, nullptr, wc.hInstance, nullptr);

// Initialize Direct3D
if (!CreateDeviceD3D(hwnd))
Expand Down
Binary file modified SndhArchivePlayer_x64.exe
Binary file not shown.
Binary file modified thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ed0f106

Please sign in to comment.