Merge pull request #210 from nukeykt/ym3438

[Core/Sound] accurate YM2612/3438 status read emulation on invalid port
This commit is contained in:
ekeeke 2018-01-29 09:39:46 +01:00 committed by GitHub
commit f3549f21b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 3 deletions

View File

@ -1355,6 +1355,9 @@ void OPN2_Clock(ym3438_t *chip, Bit16s *buffer)
buffer[0] = chip->mol; buffer[0] = chip->mol;
buffer[1] = chip->mor; buffer[1] = chip->mor;
if (chip->status_time)
chip->status_time--;
} }
void OPN2_Write(ym3438_t *chip, Bit32u port, Bit8u data) void OPN2_Write(ym3438_t *chip, Bit32u port, Bit8u data)
@ -1411,18 +1414,30 @@ Bit8u OPN2_Read(ym3438_t *chip, Bit32u port)
} }
if (chip->mode_test_21[7]) if (chip->mode_test_21[7])
{ {
return testdata & 0xff; chip->status = testdata & 0xff;
} }
else else
{ {
return testdata >> 8; chip->status = testdata >> 8;
} }
} }
else else
{ {
return (chip->busy << 7) | (chip->timer_b_overflow_flag << 1) chip->status = (chip->busy << 7) | (chip->timer_b_overflow_flag << 1)
| chip->timer_a_overflow_flag; | chip->timer_a_overflow_flag;
} }
if (chip_type == ym3438_type_ym2612)
{
chip->status_time = 300000;
}
else
{
chip->status_time = 40000000;
}
}
if (chip->status_time)
{
return chip->status;
} }
return 0; return 0;
} }

View File

@ -205,6 +205,8 @@ typedef struct
Bit8u pan_l[6], pan_r[6]; Bit8u pan_l[6], pan_r[6];
Bit8u ams[6]; Bit8u ams[6];
Bit8u pms[6]; Bit8u pms[6];
Bit8u status;
Bit32u status_time;
} ym3438_t; } ym3438_t;
void OPN2_Reset(ym3438_t *chip); void OPN2_Reset(ym3438_t *chip);