diff --git a/src/engine/fileOps/it.cpp b/src/engine/fileOps/it.cpp index e8d64f046..d5cac587b 100644 --- a/src/engine/fileOps/it.cpp +++ b/src/engine/fileOps/it.cpp @@ -44,17 +44,10 @@ bool DivEngine::loadIT(unsigned char* file, size_t len) { ds.noSlidesOnFirstTick=true; ds.rowResetsArpPos=true; ds.ignoreJumpAtEnd=false; - ds.pitchSlideSpeed=12; + ds.pitchSlideSpeed=4; - ds.system[0]=DIV_SYSTEM_DUMMY; - ds.system[1]=DIV_SYSTEM_DUMMY; - ds.system[2]=DIV_SYSTEM_DUMMY; - ds.system[3]=DIV_SYSTEM_DUMMY; - ds.system[4]=DIV_SYSTEM_DUMMY; - ds.system[5]=DIV_SYSTEM_DUMMY; - ds.system[6]=DIV_SYSTEM_DUMMY; - ds.system[7]=DIV_SYSTEM_DUMMY; - ds.systemLen=8; + ds.system[0]=DIV_SYSTEM_ES5506; + ds.systemLen=1; logV("Impulse Tracker module"); @@ -143,6 +136,114 @@ bool DivEngine::loadIT(unsigned char* file, size_t len) { for (int i=0; iname=reader.readString(26); + + if (compatTracker<0x200) { // old format + // x + reader.readC(); + reader.readC(); + reader.readC(); + reader.readC(); + reader.readC(); + reader.readC(); + } else { // new format + // filter params + initCut=reader.readC(); + initRes=reader.readC(); + + // MIDI stuff - ignored + reader.readI(); + } + + logV("filter: %d/%d",initCut,initRes); + + // note map + ins->amiga.useNoteMap=true; + for (int j=0; j<120; j++) { + ins->amiga.noteMap[j].freq=(unsigned char)reader.readC(); + ins->amiga.noteMap[j].map=reader.readC()-1; + } + + // TODO: envelopes... + ds.ins.push_back(ins); } @@ -150,6 +251,149 @@ bool DivEngine::loadIT(unsigned char* file, size_t len) { for (int i=0; iname=reader.readString(26); + + unsigned char convert=reader.readC(); + unsigned char defPan=reader.readC(); + + logV("defPan: %d",defPan); + + if (flags&2) { + s->depth=DIV_SAMPLE_DEPTH_16BIT; + } else { + s->depth=DIV_SAMPLE_DEPTH_8BIT; + } + + if (flags&8) { + logE("sample decompression not implemented!"); + lastError="sample decompression not implemented"; + delete s; + delete[] file; + return false; + } + + s->init((unsigned int)reader.readI()); + s->loopStart=reader.readI(); + s->loopEnd=reader.readI(); + s->centerRate=reader.readI()/2; + if (flags&16) { + s->loop=true; + if (flags&64) { + s->loopMode=DIV_SAMPLE_LOOP_PINGPONG; + } else { + s->loopMode=DIV_SAMPLE_LOOP_FORWARD; + } + } + if (flags&32) { + s->loop=true; + if (flags&128) { + s->loopMode=DIV_SAMPLE_LOOP_PINGPONG; + } else { + s->loopMode=DIV_SAMPLE_LOOP_FORWARD; + } + s->loopStart=reader.readI(); + s->loopEnd=reader.readI(); + } else { + reader.readI(); + reader.readI(); + } + + unsigned int dataPtr=reader.readI(); + + unsigned char vibSpeed=reader.readC(); + unsigned char vibDepth=reader.readC(); + unsigned char vibRate=reader.readC(); + unsigned char vibShape=reader.readC(); + + logV("vibrato: %d %d %d %d",vibSpeed,vibDepth,vibRate,vibShape); + + if (s->samples>0) { + logD("seek to %x...",dataPtr); + if (!reader.seek(dataPtr,SEEK_SET)) { + logE("premature end of file!"); + lastError="incomplete file"; + delete s; + delete[] file; + return false; + } + } else { + logD("seek not needed..."); + } + + if (s->depth==DIV_SAMPLE_DEPTH_16BIT) { + if (flags&4) { // downmix stereo + for (unsigned int i=0; isamples; i++) { + short l; + short r; + if (convert&2) { + l=reader.readS_BE(); + r=reader.readS_BE(); + } else { + l=reader.readS(); + r=reader.readS(); + } + if (!(convert&1)) { + l^=0x8000; + r^=0x8000; + } + s->data16[i]=(l+r)>>1; + } + } else { + for (unsigned int i=0; isamples; i++) { + if (convert&2) { + s->data16[i]=reader.readS_BE()^((convert&1)?0:0x8000); + } else { + s->data16[i]=reader.readS()^((convert&1)?0:0x8000); + } + } + } + } else { + if (flags&4) { // downmix stereo + for (unsigned int i=0; isamples; i++) { + signed char l=reader.readC(); + signed char r=reader.readC(); + if (!(convert&1)) { + l^=0x80; + r^=0x80; + } + s->data8[i]=(l+r)>>1; + } + } else { + for (unsigned int i=0; isamples; i++) { + s->data8[i]=reader.readC()^((convert&1)?0:0x80); + } + } + } + ds.sample.push_back(s); }