summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqwx <devnull@localhost>2018-07-21 05:05:53 +0200
committerqwx <devnull@localhost>2018-07-21 05:05:53 +0200
commitf4b9f0304dee1e94dbee35e30765f8a7349794ba (patch)
tree46dff79dadfb28357296b5fc3208d6308c54e3da
parent2d6f9f4700f572f09c28994af05c32d9365bf2ad (diff)
dmid: better fnumber calculation and fix fine tuning for 2nd voice
-rw-r--r--sys/src/games/dmid.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/sys/src/games/dmid.c b/sys/src/games/dmid.c
index 7778e19c0..a7da7ea0e 100644
--- a/sys/src/games/dmid.c
+++ b/sys/src/games/dmid.c
@@ -31,7 +31,7 @@ enum{
struct Inst{
int fixed;
int dbl;
- uchar fine;
+ int fine;
uchar n;
uchar i[13];
uchar i2[13];
@@ -225,13 +225,16 @@ getch(void)
void
setoct(Opl *o)
{
- int n, b, f;
-
- n = o->n + o->c->bend / 0x1000 & 0x7f;
- f = freq[n] + (o->c->bend % 0x1000) * (freq[n+1] - freq[n]) / 0x1000;
- f = (f * (1 << 20)) / 49716;
- //if(o->i == o->c->i->i2)
- // f += o->c->i->fine; /* nope */
+ int n, b, f, d;
+ double e;
+
+ d = o->c->bend;
+ d += o->i == o->c->i->i2 ? o->c->i->fine : 0;
+ n = o->n + d / 0x1000 & 0x7f;
+ e = freq[n] + (d % 0x1000) * (freq[n+1] - freq[n]) / 0x1000;
+ if(o->c->i->fixed)
+ e = (double)(int)e;
+ f = (e * (1 << 20)) / 49716;
for(b=1; b<8; b++, f>>=1)
if(f < 1024)
break;
@@ -448,7 +451,7 @@ readinst(char *file)
i->fixed = n & 1<<0;
i->dbl = opl2 ? 0 : n & 1<<2;
get8(nil);
- i->fine = get8(nil) / 2 - 64;
+ i->fine = (get8(nil) - 128) * 64;
i->n = get8(nil);
bread(i->i, sizeof i->i);
get8(nil);