Merge branch 'master' into sample_banks
This commit is contained in:
commit
e3e61c817c
183 changed files with 1384 additions and 777 deletions
|
|
@ -2094,6 +2094,12 @@ bool DivEngine::loadFur(unsigned char* file, size_t len, int variantID) {
|
|||
ds.systemFlags[i].set("oldPitch",true);
|
||||
}
|
||||
}
|
||||
} else if (ds.version<217) {
|
||||
for (int i=0; i<ds.systemLen; i++) {
|
||||
if (ds.system[i]==DIV_SYSTEM_VERA) {
|
||||
ds.systemFlags[i].set("chipType",1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (active) quitDispatch();
|
||||
|
|
|
|||
|
|
@ -639,6 +639,8 @@ bool DivEngine::loadIT(unsigned char* file, size_t len) {
|
|||
logD("seek not needed...");
|
||||
}
|
||||
|
||||
logV("reading sample data (%d)",s->samples);
|
||||
|
||||
if (flags&8) { // compressed sample
|
||||
unsigned int ret=0;
|
||||
logV("decompression begin... (%d)",s->samples);
|
||||
|
|
@ -672,62 +674,66 @@ bool DivEngine::loadIT(unsigned char* file, size_t len) {
|
|||
}
|
||||
logV("got: %d",ret);
|
||||
} else {
|
||||
if (s->depth==DIV_SAMPLE_DEPTH_16BIT) {
|
||||
if (flags&4) { // downmix stereo
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
short l;
|
||||
if (convert&2) {
|
||||
l=reader.readS_BE();
|
||||
} else {
|
||||
l=reader.readS();
|
||||
try {
|
||||
if (s->depth==DIV_SAMPLE_DEPTH_16BIT) {
|
||||
if (flags&4) { // downmix stereo
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
short l;
|
||||
if (convert&2) {
|
||||
l=reader.readS_BE();
|
||||
} else {
|
||||
l=reader.readS();
|
||||
}
|
||||
if (!(convert&1)) {
|
||||
l^=0x8000;
|
||||
}
|
||||
s->data16[i]=l;
|
||||
}
|
||||
if (!(convert&1)) {
|
||||
l^=0x8000;
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
short r;
|
||||
if (convert&2) {
|
||||
r=reader.readS_BE();
|
||||
} else {
|
||||
r=reader.readS();
|
||||
}
|
||||
if (!(convert&1)) {
|
||||
r^=0x8000;
|
||||
}
|
||||
s->data16[i]=(s->data16[i]+r)>>1;
|
||||
}
|
||||
s->data16[i]=l;
|
||||
}
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
short r;
|
||||
if (convert&2) {
|
||||
r=reader.readS_BE();
|
||||
} else {
|
||||
r=reader.readS();
|
||||
} else {
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
if (convert&2) {
|
||||
s->data16[i]=reader.readS_BE()^((convert&1)?0:0x8000);
|
||||
} else {
|
||||
s->data16[i]=reader.readS()^((convert&1)?0:0x8000);
|
||||
}
|
||||
}
|
||||
if (!(convert&1)) {
|
||||
r^=0x8000;
|
||||
}
|
||||
s->data16[i]=(s->data16[i]+r)>>1;
|
||||
}
|
||||
} else {
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
if (convert&2) {
|
||||
s->data16[i]=reader.readS_BE()^((convert&1)?0:0x8000);
|
||||
} else {
|
||||
s->data16[i]=reader.readS()^((convert&1)?0:0x8000);
|
||||
if (flags&4) { // downmix stereo
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
signed char l=reader.readC();
|
||||
if (!(convert&1)) {
|
||||
l^=0x80;
|
||||
}
|
||||
s->data8[i]=l;
|
||||
}
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
signed char r=reader.readC();
|
||||
if (!(convert&1)) {
|
||||
r^=0x80;
|
||||
}
|
||||
s->data8[i]=(s->data8[i]+r)>>1;
|
||||
}
|
||||
} else {
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
s->data8[i]=reader.readC()^((convert&1)?0:0x80);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (flags&4) { // downmix stereo
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
signed char l=reader.readC();
|
||||
if (!(convert&1)) {
|
||||
l^=0x80;
|
||||
}
|
||||
s->data8[i]=l;
|
||||
}
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
signed char r=reader.readC();
|
||||
if (!(convert&1)) {
|
||||
r^=0x80;
|
||||
}
|
||||
s->data8[i]=(s->data8[i]+r)>>1;
|
||||
}
|
||||
} else {
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
s->data8[i]=reader.readC()^((convert&1)?0:0x80);
|
||||
}
|
||||
}
|
||||
} catch (EndOfFileException& e) {
|
||||
logW("premature end of file...");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ static void readSbiOpData(sbi_t& sbi, SafeReader& reader) {
|
|||
bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
||||
struct InvalidHeaderException {};
|
||||
bool success=false;
|
||||
bool opl2=!getConfInt("s3mOPL3",0);
|
||||
char magic[4]={0,0,0,0};
|
||||
SafeReader reader=SafeReader(file,len);
|
||||
warnings="";
|
||||
|
|
@ -273,11 +274,16 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
|||
bool hasPCM=false;
|
||||
bool hasFM=false;
|
||||
int numChans=0;
|
||||
int realNumChans=0;
|
||||
|
||||
for (int i=0; i<32; i++) {
|
||||
if (chanSettings[i]==255) continue;
|
||||
if ((chanSettings[i]&127)>=32) continue;
|
||||
if ((chanSettings[i]&127)>=16) {
|
||||
for (int ch=0; ch<32; ch++) {
|
||||
if (chanSettings[ch]!=255) realNumChans++;
|
||||
}
|
||||
|
||||
for (int ch=0; ch<32; ch++) {
|
||||
if (chanSettings[ch]==255) continue;
|
||||
if ((chanSettings[ch]&127)>=32) continue;
|
||||
if ((chanSettings[ch]&127)>=16) {
|
||||
hasFM=true;
|
||||
} else {
|
||||
hasPCM=true;
|
||||
|
|
@ -287,34 +293,69 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
|||
if (hasFM && hasPCM) break;
|
||||
}
|
||||
|
||||
int pcmChan=hasFM?9:0;
|
||||
int pcmChan=hasFM?(opl2 ? 9 : 18):0;
|
||||
int fmChan=hasPCM?32:0;
|
||||
int invalidChan=40;
|
||||
|
||||
for (int i=0; i<32; i++) {
|
||||
if (chanSettings[i]==255) {
|
||||
chanMap[i]=invalidChan++;
|
||||
for (int ch=0; ch<32; ch++) {
|
||||
if (chanSettings[ch]==255) {
|
||||
chanMap[ch]=invalidChan++;
|
||||
continue;
|
||||
}
|
||||
if ((chanSettings[i]&127)>=32) {
|
||||
chanMap[i]=invalidChan++;
|
||||
if ((chanSettings[ch]&127)>=32) {
|
||||
chanMap[ch]=invalidChan++;
|
||||
continue;
|
||||
}
|
||||
if ((chanSettings[i]&127)>=16) {
|
||||
chanMap[i]=fmChan++;
|
||||
if ((chanSettings[ch]&127)>=16) {
|
||||
chanMap[ch]=fmChan++;
|
||||
} else {
|
||||
chanMap[i]=pcmChan++;
|
||||
chanMap[ch]=pcmChan++;
|
||||
}
|
||||
}
|
||||
|
||||
char buffer[40];
|
||||
int chanIndex = 1;
|
||||
|
||||
if (hasPCM) {
|
||||
for (int i=pcmChan; i<32; i++) {
|
||||
ds.subsong[0]->chanShow[i]=false;
|
||||
ds.subsong[0]->chanShowChanOsc[i]=false;
|
||||
for(int ch = 0; ch < pcmChan - (realNumChans - (hasFM ? 9 : 0)); ch++)
|
||||
{
|
||||
ds.subsong[0]->chanShow[ch]=false;
|
||||
ds.subsong[0]->chanShowChanOsc[ch]=false;
|
||||
}
|
||||
|
||||
for (int ch=pcmChan; ch<32; ch++) {
|
||||
ds.subsong[0]->chanShow[ch]=false;
|
||||
ds.subsong[0]->chanShowChanOsc[ch]=false;
|
||||
}
|
||||
|
||||
for(int ch = 0; ch < 32; ch++)
|
||||
{
|
||||
if(ds.subsong[0]->chanShow[ch])
|
||||
{
|
||||
snprintf(buffer, 40, _("Channel %d"), chanIndex);
|
||||
ds.subsong[0]->chanName[ch] = buffer;
|
||||
chanIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasFM && !opl2) {
|
||||
for (int ch=(hasPCM?32:0) + 9; ch<(hasPCM?32:0) + 18; ch++) {
|
||||
ds.subsong[0]->chanShow[ch]=false;
|
||||
ds.subsong[0]->chanShowChanOsc[ch]=false;
|
||||
}
|
||||
|
||||
chanIndex = 1;
|
||||
|
||||
for (int ch=(hasPCM?32:0); ch<(hasPCM?32:0) + 9; ch++) {
|
||||
snprintf(buffer, 40, _("FM %d"), chanIndex);
|
||||
ds.subsong[0]->chanName[ch] = buffer;
|
||||
chanIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
logV("numChans: %d",numChans);
|
||||
logV("realNumChans: %d",realNumChans);
|
||||
|
||||
ds.systemName="PC";
|
||||
if (hasPCM) {
|
||||
|
|
@ -327,7 +368,7 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
|||
ds.systemLen++;
|
||||
}
|
||||
if (hasFM) {
|
||||
ds.system[ds.systemLen]=DIV_SYSTEM_OPL2;
|
||||
ds.system[ds.systemLen]=opl2 ? DIV_SYSTEM_OPL2 : DIV_SYSTEM_OPL3;
|
||||
ds.systemVol[ds.systemLen]=1.0f;
|
||||
ds.systemPan[ds.systemLen]=0;
|
||||
ds.systemLen++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue