From 905aa1b1a1e2167bca08b6d5730f99aeb7207aeb Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 26 May 2022 23:19:27 -0500 Subject: [PATCH] SMS: add TI PSG volume table --- extern/Nuked-PSG/ympsg.c | 22 +++++++++++++++------- extern/Nuked-PSG/ympsg.h | 4 ++++ src/engine/platform/sms.cpp | 6 +++++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/extern/Nuked-PSG/ympsg.c b/extern/Nuked-PSG/ympsg.c index f6b8247b3..4aaeac2df 100644 --- a/extern/Nuked-PSG/ympsg.c +++ b/extern/Nuked-PSG/ympsg.c @@ -8,6 +8,10 @@ const float ympsg_vol[17] = { 1.0, 0.772, 0.622, 0.485, 0.382, 0.29, 0.229, 0.174, 0.132, 0.096, 0.072, 0.051, 0.034, 0.019, 0.009, 0.0, -1.059 }; +const float tipsg_vol[17] = { + 1.0, 0.794, 0.631, 0.501, 0.398, 0.316, 0.251, 0.2, 0.158, 0.126, 0.1, 0.079, 0.063, 0.05, 0.04, 0.0, -1.059 +}; + static void YMPSG_WriteLatch(ympsg_t *chip) { uint8_t data = chip->data; @@ -260,6 +264,10 @@ void YMPSG_Init(ympsg_t *chip, uint8_t real_sn) YMPSG_SetIC(chip, 1); chip->noise_tap2 = real_sn ? 13 : 15; chip->noise_size = real_sn ? 16383 : 32767; + for (i = 0; i < 17; i++) + { + chip->vol_table[i]=real_sn?tipsg_vol[i]:ympsg_vol[i]; + } for (i = 0; i < 16; i++) { YMPSG_Clock(chip); @@ -314,22 +322,22 @@ float YMPSG_GetOutput(ympsg_t *chip) YMPSG_UpdateSample(chip); if (chip->test & 1) { - sample += ympsg_vol[chip->volume_out[chip->test >> 1]]; - sample += ympsg_vol[16] * 3.f; + sample += chip->vol_table[chip->volume_out[chip->test >> 1]]; + sample += chip->vol_table[16] * 3.f; } else if (!chip->mute) { - sample += ympsg_vol[chip->volume_out[0]]; - sample += ympsg_vol[chip->volume_out[1]]; - sample += ympsg_vol[chip->volume_out[2]]; - sample += ympsg_vol[chip->volume_out[3]]; + sample += chip->vol_table[chip->volume_out[0]]; + sample += chip->vol_table[chip->volume_out[1]]; + sample += chip->vol_table[chip->volume_out[2]]; + sample += chip->vol_table[chip->volume_out[3]]; } else { for (i = 0; i < 4; i++) { if (!((chip->mute>>i) & 1)) - sample += ympsg_vol[chip->volume_out[i]]; + sample += chip->vol_table[chip->volume_out[i]]; } } return sample; diff --git a/extern/Nuked-PSG/ympsg.h b/extern/Nuked-PSG/ympsg.h index 063105809..2465f5c33 100644 --- a/extern/Nuked-PSG/ympsg.h +++ b/extern/Nuked-PSG/ympsg.h @@ -58,6 +58,10 @@ typedef struct { uint64_t writebuf_lasttime; ympsg_writebuf writebuf[YMPSG_WRITEBUF_SIZE]; + // + float vol_table[17]; + + uint8_t mute; } ympsg_t; diff --git a/src/engine/platform/sms.cpp b/src/engine/platform/sms.cpp index c0dd9ed5b..57e868bd4 100644 --- a/src/engine/platform/sms.cpp +++ b/src/engine/platform/sms.cpp @@ -42,6 +42,7 @@ const char* DivPlatformSMS::getEffectName(unsigned char effect) { } void DivPlatformSMS::acquire_nuked(short* bufL, short* bufR, size_t start, size_t len) { + int o=0; for (size_t h=start; h32767) o=32767; + bufL[h]=o; /* for (int i=0; i<4; i++) { if (isMuted[i]) {