summaryrefslogtreecommitdiff
path: root/src/i_oplmusic.c
diff options
context:
space:
mode:
authorSimon Howard2009-03-12 18:50:15 +0000
committerSimon Howard2009-03-12 18:50:15 +0000
commit90fd85b32dd85884fb9a9cf0a7063c4509147d40 (patch)
treedab137bf237e34270adadd6560669cee6c9e00f4 /src/i_oplmusic.c
parent99420c03a1cb10ea69207f2ed89f5fd1ec892bee (diff)
downloadchocolate-doom-90fd85b32dd85884fb9a9cf0a7063c4509147d40.tar.gz
chocolate-doom-90fd85b32dd85884fb9a9cf0a7063c4509147d40.tar.bz2
chocolate-doom-90fd85b32dd85884fb9a9cf0a7063c4509147d40.zip
Read from register port when doing register writes during startup phase;
afterwards, read from the data port. Subversion-branch: /branches/opl-branch Subversion-revision: 1464
Diffstat (limited to 'src/i_oplmusic.c')
-rw-r--r--src/i_oplmusic.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/i_oplmusic.c b/src/i_oplmusic.c
index baf17bd6..0543be2e 100644
--- a/src/i_oplmusic.c
+++ b/src/i_oplmusic.c
@@ -116,6 +116,13 @@ static genmidi_instr_t *percussion_instrs;
static opl_voice_t voices[OPL_NUM_VOICES];
static opl_voice_t *voice_free_list;
+// In the initialisation stage, register writes are spaced by reading
+// from the register port (0). After initialisation, spacing is
+// peformed by reading from the data port instead. I have no idea
+// why.
+
+static boolean init_stage_reg_writes = false;
+
// Configuration file variable, containing the port number for the
// adlib chip.
@@ -139,7 +146,18 @@ static void WriteRegister(int reg, int value)
for (i=0; i<6; ++i)
{
- GetStatus();
+ // An oddity of the Doom OPL code: at startup initialisation,
+ // the spacing here is performed by reading from the register
+ // port; after initialisation, the data port is read, instead.
+
+ if (init_stage_reg_writes)
+ {
+ OPL_ReadPort(OPL_REGISTER_PORT);
+ }
+ else
+ {
+ OPL_ReadPort(OPL_DATA_PORT);
+ }
}
OPL_WritePort(OPL_DATA_PORT, value);
@@ -393,6 +411,8 @@ static boolean I_OPL_InitMusic(void)
return false;
}
+ init_stage_reg_writes = true;
+
// Doom does the detection sequence twice, for some reason:
if (!DetectOPL() || !DetectOPL())
@@ -413,6 +433,11 @@ static boolean I_OPL_InitMusic(void)
InitRegisters();
InitVoices();
+ // Now that initialisation has finished, switch the
+ // register writing mode:
+
+ init_stage_reg_writes = false;
+
#ifdef TEST
{
opl_voice_t *voice;