Skip to content

Commit 3e2dc44

Browse files
gurceilgblgblgb
authored andcommitted
MEGA65: attempt to let hdmi output master control co-efficients map to xemu master volume #272
git cherry-pick from gurcei@47b105e from @gurcei thanks!
1 parent 21518c0 commit 3e2dc44

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

targets/mega65/io_mapper.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ int core_age_in_days;
4848
static const Uint8 fpga_firmware_version[] = { 'X','e','m','u' };
4949
static const Uint8 cpld_firmware_version[] = { 'N','o','w','!' };
5050

51+
static Uint8 coeff_addr = 0x00;
52+
static Uint8 mixer_coeffs[0x100];
5153

5254
#define RETURN_ON_IO_READ_NOT_IMPLEMENTED(func, fb) \
5355
do { DEBUG("IO: NOT IMPLEMENTED read (emulator lacks feature), %s $%04X fallback to answer $%02X" NL, func, addr, fb); \
@@ -342,6 +344,22 @@ Uint8 io_read ( unsigned int addr )
342344
}
343345
}
344346

347+
void update_mixer_coeffs(Uint8 data)
348+
{
349+
mixer_coeffs[coeff_addr] = data;
350+
351+
if (coeff_addr == 0x1E || coeff_addr == 0x1F) { // HDMI-LEFT?
352+
int vol = (mixer_coeffs[0x1E] << 8) + mixer_coeffs[0x1F];
353+
vol = vol * 100 / 65536;
354+
audio_set_stereo_parameters(vol, AUDIO_UNCHANGED_SEPARATION);
355+
}
356+
357+
if (coeff_addr == 0x3E || coeff_addr == 0x3F) { // HDMI-RIGHT?
358+
int vol = (mixer_coeffs[0x3E] << 8) + mixer_coeffs[0x3F];
359+
vol = vol * 100 / 65536;
360+
audio_set_stereo_parameters(vol, AUDIO_UNCHANGED_SEPARATION);
361+
}
362+
}
345363

346364

347365
/* Please read comments at io_read() above, those apply here too.
@@ -463,6 +481,14 @@ void io_write ( unsigned int addr, Uint8 data )
463481
eth65_write_reg(addr, data);
464482
return;
465483
}
484+
485+
if (addr == 0xF4) { // audio mixer co-efficient address
486+
coeff_addr = data;
487+
}
488+
if (addr == 0XF5) { // audio mixer co-efficient value
489+
update_mixer_coeffs(data);
490+
}
491+
466492
static int d6cf_exit_status = 0x42;
467493
switch (addr) {
468494
case 0x0A: // write bit 7 is zero -> flush the queue

0 commit comments

Comments
 (0)