Skip to content

Conversation

@Vincent-Halver
Copy link
Contributor

-cdicdic: Add audio attenuation (fixes #12852) [Vincent Halver]

@galibert
Copy link
Member

galibert commented Nov 5, 2025

Compiling src/mame/philips/cdislavehle.cpp...
../../../../../src/mame/philips/cdislavehle.cpp:233:43: error: 'm_cdic' is a protected member of 'cdi_state'
233 | dynamic_cast<cdi_state*>(m_owner)->m_cdic->atten_w(m_in_buf);
| ^
In file included from ../../../../../src/mame/philips/cdislavehle.cpp:32:
../../../../../src/mame/philips/cdi.h:57:34: note: declared protected here
57 | optional_device<cdicdic_device> m_cdic;
| ^

Also, this is kind of atrocious code. What are you trying to do exactly?

{
case 0xc0: case 0xc1: case 0xc2: case 0xc3: case 0xc4: case 0xc5: case 0xc6: case 0xc7:
case 0xc8: case 0xc9: case 0xca: case 0xcb: case 0xcc: case 0xcd: case 0xce: case 0xcf:
dynamic_cast<cdi_state*>(m_owner)->m_cdic->atten_w(m_in_buf);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unportable, you should rather provide this communication thru devcb_write8::array<4>.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. If it is acceptable, I will use a follow up PR on this detail.

Copy link
Contributor

@MooglyGuy MooglyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Covered some finer points on both OG's and Angelo's comments.

m_atten[0] = ((args[0] & 0x8) << 7) | args[1];
m_atten[1] = ((args[0] & 0x4) << 7) | args[2];
m_atten[2] = ((args[0] & 0x2) << 7) | args[3];
m_atten[3] = ((args[0] & 0x1) << 7) | args[4];
Copy link
Contributor

@MooglyGuy MooglyGuy Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following on from Kale's comment, it's pretty unlikely that the real hardware connection between the SLAVE and CDIC devices is 20 individual traces for the 20 bits of state represented by args here.

The correct way to do this would be to have atten_w take a single uint8_t, have a private member that increments on each call from 0 to 4 and wrapping around, in order to determine how to apply the incoming byte to the m_atten array. You would then have a devcb_write8 with a public callback-registration function in cdislavehle_device - there are plenty of examples throughout the codebase on how to do this - and then in the machine configuration function for cdi_state::cdimono1_base, do -

m_slave_hle->atten_callback().set(m_cdic, FUNC(cdicdic_device::atten_w));

rather than grabbing into a protected class member in a way that doesn't compile.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a temporary fix to expose the cdic for dynamic casting just so that it compiles so it can be validated it worked. Thanks for the feedback, I'll look into the callback change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the example. Excluding the Mute bits here will result in popping sounds. Hotel Mario shows that this solution is close, but not entirely correct. I don't exactly know what the correct technical implementation is supposed to be yet.

If it is acceptable, I will commit this in the (largely) working state. I have left a TODO here.

-cdicdic: Add audio attenuation. Fixes mamedev#12852 [Vincent Halver]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CD-i] Sound mixing not faithful to the real machine

4 participants