swan: Add command to change internal speaker loudness

This commit is contained in:
Adrian Siekierka 2025-03-08 20:06:01 +01:00 committed by tildearrow
parent b59fc1e8f5
commit c93dc6f4f3
5 changed files with 24 additions and 3 deletions

View file

@ -171,8 +171,9 @@ enum DivDispatchCmds {
DIV_CMD_X1_010_AUTO_ENVELOPE,
DIV_CMD_X1_010_SAMPLE_BANK_SLOT,
DIV_CMD_WS_SWEEP_TIME,
DIV_CMD_WS_SWEEP_AMOUNT,
DIV_CMD_WS_SWEEP_TIME, // (time)
DIV_CMD_WS_SWEEP_AMOUNT, // (value)
DIV_CMD_WS_GLOBAL_SPEAKER_VOLUME, // (multiplier)
DIV_CMD_N163_WAVE_POSITION,
DIV_CMD_N163_WAVE_LENGTH,

View file

@ -421,6 +421,17 @@ int DivPlatformSwan::dispatch(DivCommand c) {
rWrite(0x0c,c.value&0xff);
}
break;
case DIV_CMD_WS_GLOBAL_SPEAKER_VOLUME:
if (c.value <= 1) {
rWrite(0x11,0x09|(3<<1));
} else if (c.value <= 3) {
rWrite(0x11,0x09|(2<<1));
} else if (c.value <= 7) {
rWrite(0x11,0x09|(1<<1));
} else {
rWrite(0x11,0x09|(0<<1));
}
break;
case DIV_CMD_NOTE_PORTA: {
int destFreq=NOTE_PERIODIC(c.value2+chan[c.chan].sampleNoteDelta);
bool return2=false;
@ -631,7 +642,7 @@ void DivPlatformSwan::setFlags(const DivConfig& flags) {
chipClock=3072000;
CHECK_CUSTOM_CLOCK;
rate=chipClock/128;
stereo=flags.getBool("stereo",false);
stereo=flags.getBool("stereo",true);
for (int i=0; i<4; i++) {
oscBuf[i]->setRate(rate);
}

View file

@ -170,6 +170,7 @@ const char* cmdName[]={
"WS_SWEEP_TIME",
"WS_SWEEP_AMOUNT",
"WS_GLOBAL_SPEAKER_VOLUME",
"N163_WAVE_POSITION",
"N163_WAVE_LENGTH",

View file

@ -1389,6 +1389,9 @@ void DivEngine::registerSystems() {
{0x12, {DIV_CMD_WS_SWEEP_TIME, _("12xx: Setup sweep period (0: disabled; 1-20: enabled/period)")}},
{0x13, {DIV_CMD_WS_SWEEP_AMOUNT, _("13xx: Set sweep amount")}},
{0x17, {DIV_CMD_SAMPLE_MODE, _("17xx: Toggle PCM mode (LEGACY)")}},
},
{
{0x20, {DIV_CMD_WS_GLOBAL_SPEAKER_VOLUME, _("20xx: Set internal speaker loudness (0-1: 100%, 2-3: 200%, 4-7: 400%, 8: 800%)")}},
}
);