1
0
Fork 0

Switch to a different way to calculate the table offsets. Thanks jmarsh

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4282
This commit is contained in:
Peter Veenstra 2019-11-11 17:23:05 +00:00
parent 8f3474ecfd
commit 92da7c45ef
2 changed files with 7 additions and 10 deletions

View file

@ -37,6 +37,7 @@
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include "dosbox.h"
#include "dbopl.h"
@ -1430,7 +1431,6 @@ void InitTables( void ) {
TremoloTable[TREMOLO_TABLE - 1 - i] = val;
}
//Create a table with offsets of the channels from the start of the chip
DBOPL::Chip* chip = 0;
for ( Bitu i = 0; i < 32; i++ ) {
Bitu index = i & 0xf;
if ( index >= 9 ) {
@ -1444,8 +1444,7 @@ void InitTables( void ) {
//Add back the bits for highest ones
if ( i >= 16 )
index += 9;
Bitu blah = reinterpret_cast<Bitu>( &(chip->chan[ index ]) );
ChanOffsetTable[i] = blah;
ChanOffsetTable[i] = (Bit16u)(index*sizeof(DBOPL::Channel));
}
//Same for operators
for ( Bitu i = 0; i < 64; i++ ) {
@ -1458,9 +1457,7 @@ void InitTables( void ) {
if ( chNum >= 12 )
chNum += 16 - 12;
Bitu opNum = ( i % 8 ) / 3;
DBOPL::Channel* chan = 0;
Bitu blah = reinterpret_cast<Bitu>( &(chan->op[opNum]) );
OpOffsetTable[i] = ChanOffsetTable[ chNum ] + blah;
OpOffsetTable[i] = ChanOffsetTable[chNum]+(Bit16u)(opNum*sizeof(DBOPL::Operator));
}
#if 0
//Stupid checks if table's are correct

View file

@ -156,7 +156,7 @@ public:
};
struct Channel {
Operator op[2];
Operator op[2]; //Leave on top of struct for simpler pointer math.
inline Operator* Op( Bitu index ) {
return &( ( this + (index >> 1) )->op[ index & 1 ]);
}
@ -192,6 +192,9 @@ struct Channel {
};
struct Chip {
//18 channels with 2 operators each. Leave on top of struct for simpler pointer math.
Channel chan[18];
//This is used as the base counter for vibrato and tremolo
Bit32u lfoCounter;
Bit32u lfoAdd;
@ -208,9 +211,6 @@ struct Chip {
//Best match attack rates for the rate of this chip
Bit32u attackRates[76];
//18 channels with 2 operators each
Channel chan[18];
Bit8u reg104;
Bit8u reg08;
Bit8u reg04;