raw opl capture problem

Here you can discuss the development of patches.

raw opl capture problem

Postby NewRisingSun » 2014-1-19 @ 19:56

I noticed a possible mistake in adlib.cpp. Registers 0xB0..0xB8 are not captured in the initial register dump, possibly to not include any notes that are already sounding when capturing begins. If a game initializes registers 0xB6..0xB8 only once and then turns percussion notes on and off by writing to 0xBD without reinitializing 0xB6..0xB8, the high bits of the frequency number will not be played back properly. Zeliard is one such game, and as expected, .DRO captures from that game sound wrong in all playback programs; some drum notes will be inaudible.

Zeliard captures correctly after the following source patch:
Code: Select all
--- adlib.cpp.old   2013-01-15 12:10:04 +0000
+++ adlib.cpp   2014-01-19 19:54:06 +0000
@@ -227,10 +227,10 @@
       Bitu i, val;
       /* Check the registers to add */
       for (i=0;i<256;i++) {
-         //Skip the note on entries
-         if (i>=0xb0 && i<=0xb8)
-            continue;
          val = (*cache)[ i ];
+         //Silence the note on entries
+         if (i>=0xb0 && i<=0xb8)
+            val &= ~0x20;
          if (val) {
             AddWrite( i, val );
          }
This silences any notes that were active before capturing was started while preserving the upper bits of the frequency number.
NewRisingSun
Oldbie
 
Posts: 741
Joined: 2005-9-02 @ 02:26

Re: raw opl capture problem

Postby Qbix » 2014-1-22 @ 07:43

Moving to patches part.
It's an interesting problem that you are touching.
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10313
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: raw opl capture problem

Postby Malvineous » 2014-3-30 @ 03:38

This is a good fix, it should help correct a few capture problems. I think however you should also zero out register 0xBD, bits 0-4 (i.e. val &= 0x1f) as well. This will prevent extra notes from sounding at the beginning of the capture in the event that rhythm mode is enabled, and rhythm notes are active at the moment the capture begins.
User avatar
Malvineous
Member
 
Posts: 419
Joined: 2006-6-11 @ 02:24
Location: Brisbane, Australia

Re: raw opl capture problem

Postby NewRisingSun » 2014-4-03 @ 18:06

Added the silencing of percussion notes, the silencing of second register set notes, plus the clearing of the register cache upon initialization. Commander Keen 4-6 would not capture properly without this additional memset command (the second register set is filled with garbage data), though I have no idea why it has never been an issue with other games.
Code: Select all
--- adlib.cpp.old   2013-01-15 12:10:04 +0000
+++ adlib.cpp   2014-04-03 18:05:11 +0000
@@ -227,14 +227,17 @@
       Bitu i, val;
       /* Check the registers to add */
       for (i=0;i<256;i++) {
-         //Skip the note on entries
-         if (i>=0xb0 && i<=0xb8)
-            continue;
          val = (*cache)[ i ];
+         //Silence the note on entries         
+         if (i>=0xb0 && i<=0xb8)
+            val &= ~0x20;
+         if (i==0xbd) val &= ~0x1f;
          if (val) {
             AddWrite( i, val );
          }
          val = (*cache)[ 0x100 + i ];
+         if (i>=0xb0 && i<=0xb8)
+            val &= ~0x20;
          if (val) {
             AddWrite( 0x100 + i, val );
          }
@@ -525,6 +528,7 @@
 
 void Module::Init( Mode m ) {
    mode = m;
+   memset(cache, 0, 0x200);
    switch ( mode ) {
    case MODE_OPL3:
    case MODE_OPL2:

NewRisingSun
Oldbie
 
Posts: 741
Joined: 2005-9-02 @ 02:26


Return to DOSBox Patches

Who is online

Users browsing this forum: No registered users and 1 guest