swan: Implement headphone/internal speaker output toggle
This commit is contained in:
parent
03b87258c8
commit
b59fc1e8f5
|
@ -127,12 +127,15 @@ void swan_sound_out(swan_sound_t *snd, uint16_t port, uint8_t value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void swan_sound_subtick(swan_sound_t *snd, uint32_t cycles) {
|
static void swan_sound_subtick(swan_sound_t *snd, uint32_t cycles) {
|
||||||
|
// TODO: Do period counters update when a channel is inactive?
|
||||||
for (int ch = 0; ch < 4; ch++) {
|
for (int ch = 0; ch < 4; ch++) {
|
||||||
snd->period_counter[ch] += cycles;
|
if (snd->ch_ctrl & (1 << ch)) {
|
||||||
uint32_t step = 2048 - snd->frequency[ch];
|
snd->period_counter[ch] += cycles;
|
||||||
while (snd->period_counter[ch] >= step) {
|
uint32_t step = 2048 - snd->frequency[ch];
|
||||||
snd->sample_index[ch] = (snd->sample_index[ch] + 1) & 0x1F;
|
while (snd->period_counter[ch] >= step) {
|
||||||
snd->period_counter[ch] -= step;
|
snd->sample_index[ch] = (snd->sample_index[ch] + 1) & 0x1F;
|
||||||
|
snd->period_counter[ch] -= step;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,8 +107,12 @@ void DivPlatformSwan::acquire(short** buf, size_t len) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[0][h] = ws.output_left;
|
if (stereo) {
|
||||||
buf[1][h] = ws.output_right;
|
buf[0][h] = ws.output_left;
|
||||||
|
buf[1][h] = ws.output_right;
|
||||||
|
} else {
|
||||||
|
buf[0][h] = ((int)ws.output_speaker - 0x80) << 8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<4; i++) {
|
for (int i=0; i<4; i++) {
|
||||||
|
@ -597,7 +601,7 @@ void DivPlatformSwan::reset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int DivPlatformSwan::getOutputCount() {
|
int DivPlatformSwan::getOutputCount() {
|
||||||
return 2;
|
return stereo?2:1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformSwan::notifyWaveChange(int wave) {
|
void DivPlatformSwan::notifyWaveChange(int wave) {
|
||||||
|
@ -627,6 +631,7 @@ void DivPlatformSwan::setFlags(const DivConfig& flags) {
|
||||||
chipClock=3072000;
|
chipClock=3072000;
|
||||||
CHECK_CUSTOM_CLOCK;
|
CHECK_CUSTOM_CLOCK;
|
||||||
rate=chipClock/128;
|
rate=chipClock/128;
|
||||||
|
stereo=flags.getBool("stereo",false);
|
||||||
for (int i=0; i<4; i++) {
|
for (int i=0; i<4; i++) {
|
||||||
oscBuf[i]->setRate(rate);
|
oscBuf[i]->setRate(rate);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ class DivPlatformSwan: public DivDispatch {
|
||||||
Channel chan[4];
|
Channel chan[4];
|
||||||
DivDispatchOscBuffer* oscBuf[4];
|
DivDispatchOscBuffer* oscBuf[4];
|
||||||
bool isMuted[4];
|
bool isMuted[4];
|
||||||
|
bool stereo=true;
|
||||||
bool pcm, sweep, furnaceDac, setPos;
|
bool pcm, sweep, furnaceDac, setPos;
|
||||||
unsigned char sampleBank, noise;
|
unsigned char sampleBank, noise;
|
||||||
int dacPeriod, dacRate;
|
int dacPeriod, dacRate;
|
||||||
|
|
|
@ -2664,7 +2664,19 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DIV_SYSTEM_SWAN:
|
case DIV_SYSTEM_SWAN: {
|
||||||
|
bool stereo=flags.getBool("stereo",true);
|
||||||
|
if (ImGui::Checkbox(_("Headphone output##_SWAN_STEREO"),&stereo)) {
|
||||||
|
altered=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (altered) {
|
||||||
|
e->lockSave([&]() {
|
||||||
|
flags.set("stereo",stereo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case DIV_SYSTEM_BUBSYS_WSG:
|
case DIV_SYSTEM_BUBSYS_WSG:
|
||||||
case DIV_SYSTEM_PET:
|
case DIV_SYSTEM_PET:
|
||||||
case DIV_SYSTEM_GA20:
|
case DIV_SYSTEM_GA20:
|
||||||
|
|
Loading…
Reference in a new issue