mirror of
https://github.com/chocolate-doom/research.git
synced 2024-11-10 07:11:34 +00:00
Fix playback of OPL2 samples with an OPL3 chip.
Subversion-branch: /research Subversion-revision: 1496
This commit is contained in:
parent
8c23c48bb7
commit
591cc474c5
1 changed files with 20 additions and 0 deletions
|
@ -7,10 +7,21 @@
|
|||
#define HEADER_STRING "DBRAWOPL"
|
||||
#define ADLIB_PORT 0x388
|
||||
|
||||
// #define DEBUG
|
||||
|
||||
void write_reg(unsigned int reg, unsigned int val)
|
||||
{
|
||||
int i;
|
||||
|
||||
// This was recorded from an OPL2, but we are probably playing
|
||||
// back on an OPL3, so we need to enable the original OPL2
|
||||
// channels. Doom does this already, but other games don't.
|
||||
|
||||
if ((reg & 0xf0) == 0xc0)
|
||||
{
|
||||
val |= 0x30;
|
||||
}
|
||||
|
||||
outb(reg, ADLIB_PORT);
|
||||
|
||||
for (i=0; i<6; ++i)
|
||||
|
@ -101,15 +112,24 @@ void play_file(char *filename)
|
|||
|
||||
if (reg == 0x00)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("usleep %i ms\n", val);
|
||||
#endif
|
||||
usleep(val * 1000);
|
||||
}
|
||||
else if (reg == 0x01)
|
||||
{
|
||||
val |= (fgetc(stream) << 8);
|
||||
#ifdef DEBUG
|
||||
printf("usleep %i ms\n", val);
|
||||
#endif
|
||||
usleep(val * 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("write_reg %02x = %02x\n", reg, val);
|
||||
#endif
|
||||
write_reg(reg, val);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue