Merge pull request #280 from richard42/trs80-coco-audio-fixes

Trs80 coco audio fixes
This commit is contained in:
R. Belmont 2015-08-17 09:37:30 -04:00
commit 6a870588f2
6 changed files with 50 additions and 32 deletions

View File

@ -153,8 +153,8 @@ protected:
void recalculate_firq(void);
// changed handlers
virtual void pia1_pa_changed(void);
virtual void pia1_pb_changed(void);
virtual void pia1_pa_changed(UINT8 data);
virtual void pia1_pb_changed(UINT8 data);
// miscellaneous
virtual void update_keyboard_input(UINT8 value, UINT8 z);
@ -208,7 +208,6 @@ private:
bool is_joystick_hires(int joystick_index);
soundmux_status_t soundmux_status(void);
UINT8 sound_value(void);
void update_sound(void);
bool joyin(void);
void poll_joystick(bool *joyin, UINT8 *buttons);
@ -244,6 +243,10 @@ private:
// DAC output
UINT8 m_dac_output;
// remember the last audio sample level from the analog sources (DAC, cart, cassette) so that we don't
// introduce step changes when the audio output is enabled/disabled via PIA1 CB2
UINT8 m_analog_audio_level;
// hires interface
emu_timer *m_hiresjoy_transition_timer[2];
bool m_hiresjoy_ca;

View File

@ -56,7 +56,7 @@ protected:
virtual void update_cart_base(UINT8 *cart_base);
/* PIA1 */
virtual void pia1_pb_changed(void);
virtual void pia1_pb_changed(UINT8 data);
private:

View File

@ -45,7 +45,7 @@ public:
required_device<printer_image_device> m_printer;
protected:
virtual void pia1_pa_changed(void);
virtual void pia1_pa_changed(UINT8 data);
};
@ -65,7 +65,7 @@ protected:
virtual DECLARE_READ8_MEMBER( ff00_read );
virtual DECLARE_WRITE8_MEMBER( ff00_write );
virtual void pia1_pb_changed(void);
virtual void pia1_pb_changed(UINT8 data);
void page_rom(bool romswitch);
};

View File

@ -183,6 +183,7 @@ void coco_state::device_reset()
/* reset state */
m_dac_output = 0;
m_analog_audio_level = 0;
m_hiresjoy_ca = false;
m_dclg_previous_bit = false;
m_dclg_output_h = 0;
@ -364,7 +365,7 @@ WRITE8_MEMBER( coco_state::pia0_pb_w )
WRITE_LINE_MEMBER( coco_state::pia0_ca2_w )
{
update_sound();
update_sound(); // analog mux SEL1 is tied to PIA0 CA2
poll_keyboard();
}
@ -376,7 +377,7 @@ WRITE_LINE_MEMBER( coco_state::pia0_ca2_w )
WRITE_LINE_MEMBER( coco_state::pia0_cb2_w )
{
update_sound();
update_sound(); // analog mux SEL2 is tied to PIA0 CB2
poll_keyboard();
}
@ -456,6 +457,8 @@ WRITE8_MEMBER( coco_state::ff20_write )
READ8_MEMBER( coco_state::pia1_pa_r )
{
// Port A: we need to specify the values of all the lines, regardless of whether
// they are in input or output mode in the DDR
return (m_cassette->input() >= 0 ? 0x01 : 0x00)
| (dac_output() << 2);
}
@ -470,6 +473,8 @@ READ8_MEMBER( coco_state::pia1_pa_r )
READ8_MEMBER( coco_state::pia1_pb_r )
{
// Port B: lines in output mode are handled automatically by the PIA object.
// We only need to specify the input lines here
UINT32 ram_size = m_ram->size();
// For the CoCo 1, the logic has been changed to only select 64K rams
@ -479,7 +484,7 @@ READ8_MEMBER( coco_state::pia1_pb_r )
// to access 32K of ram, and also allows the cocoe driver to access
// the full 64K, as this uses Color Basic 1.2, which can configure 64K rams
bool memory_sense = (ram_size >= 0x4000 && ram_size <= 0x7FFF)
|| (ram_size >= 0x8000 && (m_pia_0->b_output() & 0x80));
|| (ram_size >= 0x8000 && (m_pia_0->b_output() & 0x40));
// serial in (PB0)
bool serial_in = (m_rs232 != NULL) && (m_rs232->rxd_r() ? true : false);
@ -497,7 +502,7 @@ READ8_MEMBER( coco_state::pia1_pb_r )
WRITE8_MEMBER( coco_state::pia1_pa_w )
{
pia1_pa_changed();
pia1_pa_changed(data);
}
@ -508,7 +513,7 @@ WRITE8_MEMBER( coco_state::pia1_pa_w )
WRITE8_MEMBER( coco_state::pia1_pb_w )
{
pia1_pb_changed();
pia1_pb_changed(data);
}
@ -532,11 +537,7 @@ WRITE_LINE_MEMBER( coco_state::pia1_ca2_w )
WRITE_LINE_MEMBER( coco_state::pia1_cb2_w )
{
poll_keyboard();
// Theoretically, I should be calling update_sound() here; however this seems to create
// a buzzing in some CoCo software (e.g. - Popcorn). This is likely because this line
// drives the MC14529B MUX, and when disabled the output probably goes hi-Z.
update_sound(); // SOUND_ENABLE is connected to PIA1 CB2
}
@ -689,10 +690,25 @@ void coco_state::update_sound(void)
UINT8 cassette_sound = (bCassSoundEnable ? 0x40 : 0);
UINT8 cart_sound = (bCartSoundEnable ? 0x40 : 0);
/* determine the value to send to the DAC */
/* determine the value to send to the DAC (this is used by the Joystick read as well as audio out) */
m_dac_output = (m_pia_1->a_output() & 0xFC) >> 2;
UINT8 dac_sound = (status == SOUNDMUX_ENABLE ? m_dac_output << 1 : 0);
m_dac->write_unsigned8(single_bit_sound + dac_sound + cassette_sound + cart_sound);
/* The CoCo uses a single DAC for both audio output and joystick axis position measurement.
* To avoid introducing artifacts while reading the axis positions, some software will disable
* the audio output while using the DAC to read the joystick. On a real CoCo, there is a low-pass
* filter (C57 on the CoCo 3) which will hold the audio level for very short periods of time,
* preventing the introduction of artifacts while the joystick value is being read. We are not going
* to simulate the exponential decay of a capacitor here. Instead, we will store and hold the last
* used analog audio output value while the audio is disabled, to avoid introducing artifacts in
* software such as Tandy's Popcorn and Sock Master's Donkey Kong.
*/
if ((status & SOUNDMUX_ENABLE) != 0)
{
m_analog_audio_level = dac_sound + cassette_sound + cart_sound;
}
m_dac->write_unsigned8(single_bit_sound + m_analog_audio_level);
/* determine the cassette sound status */
cassette_state cas_sound = bCassSoundEnable ? CASSETTE_SPEAKER_ENABLED : CASSETTE_SPEAKER_MUTED;
@ -981,12 +997,12 @@ void coco_state::update_prinout(bool prinout)
// pia1_pa_changed - called when PIA1 PA changes
//-------------------------------------------------
void coco_state::pia1_pa_changed(void)
void coco_state::pia1_pa_changed(UINT8 data)
{
update_sound();
update_sound(); // DAC is connected to PIA1 PA2-PA7
poll_keyboard();
update_cassout(dac_output());
update_prinout(m_pia_1->a_output() & 0x02 ? true : false);
update_prinout(data & 0x02 ? true : false);
}
@ -995,9 +1011,9 @@ void coco_state::pia1_pa_changed(void)
// pia1_pb_changed - called when PIA1 PB changes
//-------------------------------------------------
void coco_state::pia1_pb_changed(void)
void coco_state::pia1_pb_changed(UINT8 data)
{
update_sound();
update_sound(); // singe_bit_sound is connected to PIA1 PB1
}

View File

@ -94,12 +94,11 @@ READ8_MEMBER( coco12_state::sam_read )
// pia1_pb_changed
//-------------------------------------------------
void coco12_state::pia1_pb_changed(void)
void coco12_state::pia1_pb_changed(UINT8 data)
{
/* call inherited function */
coco_state::pia1_pb_changed();
coco_state::pia1_pb_changed(data);
UINT8 data = m_pia_1->b_output();
m_vdg->css_w(data & 0x08);
m_vdg->intext_w(data & 0x10);
m_vdg->gm0_w(data & 0x10);

View File

@ -48,13 +48,13 @@ easier to manage.
// pia1_pa_changed - called when PIA1 PA changes
//-------------------------------------------------
void dragon_state::pia1_pa_changed(void)
void dragon_state::pia1_pa_changed(UINT8 data)
{
/* call inherited function */
coco12_state::pia1_pa_changed();
coco12_state::pia1_pa_changed(data);
/* if strobe bit is high send data from pia0 port b to dragon parallel printer */
if (m_pia_1->a_output() & 0x02)
if (data & 0x02)
{
UINT8 output = m_pia_1->b_output();
m_printer->output(output);
@ -113,9 +113,9 @@ WRITE8_MEMBER( dragon64_state::ff00_write )
// pia1_pb_changed
//-------------------------------------------------
void dragon64_state::pia1_pb_changed(void)
void dragon64_state::pia1_pb_changed(UINT8 data)
{
dragon_state::pia1_pb_changed();
dragon_state::pia1_pb_changed(data);
UINT8 ddr = ~m_pia_1->port_b_z_mask();
@ -125,7 +125,7 @@ void dragon64_state::pia1_pb_changed(void)
/* always be high (enabling 32k basic rom) */
if (ddr & 0x04)
{
page_rom(m_pia_1->b_output() & 0x04 ? true : false);
page_rom(data & 0x04 ? true : false);
logerror("pia1_pb_changed\n");
}
}