neo geo: finish it up
This commit is contained in:
parent
fbd94bbce9
commit
20a9282efe
|
@ -870,7 +870,6 @@ void DivEngine::renderSamples() {
|
|||
s->rendData=new short[s->rendLength];
|
||||
size_t adpcmLen=((s->rendLength>>1)+255)&0xffffff00;
|
||||
s->adpcmRendLength=adpcmLen;
|
||||
printf("al: %x\n",s->adpcmRendLength);
|
||||
s->adpcmRendData=new unsigned char[adpcmLen];
|
||||
memset(s->adpcmRendData,0,adpcmLen);
|
||||
|
||||
|
@ -951,6 +950,24 @@ void DivEngine::renderSamples() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// step 3: allocate the samples if needed
|
||||
if (song.system==DIV_SYSTEM_YM2610 || song.system==DIV_SYSTEM_YM2610_EXT) {
|
||||
if (adpcmMem==NULL) adpcmMem=new unsigned char[16777216];
|
||||
|
||||
size_t memPos=0;
|
||||
for (int i=0; i<song.sampleLen; i++) {
|
||||
DivSample* s=song.sample[i];
|
||||
if ((memPos&0xf00000)!=((memPos+s->adpcmRendLength)&0xf00000)) {
|
||||
|
||||
memPos=(memPos+0xfffff)&0xf00000;
|
||||
printf("aligning to %lx.\n",memPos);
|
||||
}
|
||||
memcpy(adpcmMem+memPos,s->adpcmRendData,s->adpcmRendLength);
|
||||
s->rendOff=memPos;
|
||||
memPos+=s->adpcmRendLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DivInstrument* DivEngine::getIns(int index) {
|
||||
|
|
|
@ -119,6 +119,8 @@ class DivEngine {
|
|||
// initialize the engine. optionally provide an output file name.
|
||||
bool init(String outName="");
|
||||
|
||||
unsigned char* adpcmMem;
|
||||
|
||||
DivEngine():
|
||||
chans(0),
|
||||
playing(false),
|
||||
|
@ -143,6 +145,7 @@ class DivEngine {
|
|||
temp{0,0},
|
||||
prevSample{0,0},
|
||||
totalProcessed(0),
|
||||
jediTable(NULL) {}
|
||||
jediTable(NULL),
|
||||
adpcmMem(NULL) {}
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -185,12 +185,13 @@ int DivPlatformYM2610::dispatch(DivCommand c) {
|
|||
writes.emplace(0x128+c.chan-7,0);
|
||||
break;
|
||||
}
|
||||
writes.emplace(0x110+c.chan-7,0);
|
||||
writes.emplace(0x118+c.chan-7,c.value%12);
|
||||
int sampleLen=(parent->song.sample[12*sampleBank+c.value%12]->adpcmRendLength-1)>>8;
|
||||
writes.emplace(0x120+c.chan-7,sampleLen&0xff);
|
||||
writes.emplace(0x128+c.chan-7,(c.value%12)+(sampleLen>>8));
|
||||
writes.emplace(0x108+(c.chan-7),0xc0|chan[c.chan].vol);
|
||||
DivSample* s=parent->song.sample[12*sampleBank+c.value%12];
|
||||
writes.emplace(0x110+c.chan-7,(s->rendOff>>8)&0xff);
|
||||
writes.emplace(0x118+c.chan-7,s->rendOff>>16);
|
||||
int end=s->rendOff+s->adpcmRendLength-1;
|
||||
writes.emplace(0x120+c.chan-7,(end>>8)&0xff);
|
||||
writes.emplace(0x128+c.chan-7,end>>16);
|
||||
writes.emplace(0x108+(c.chan-7),(chan[c.chan].pan<<6)|chan[c.chan].vol);
|
||||
writes.emplace(0x100,0x00|(1<<(c.chan-7)));
|
||||
break;
|
||||
}
|
||||
|
@ -242,7 +243,8 @@ int DivPlatformYM2610::dispatch(DivCommand c) {
|
|||
}
|
||||
case DIV_CMD_NOTE_OFF:
|
||||
if (c.chan>6) {
|
||||
dacSample=-1;
|
||||
writes.emplace(0x100,0x80|(1<<(c.chan-7)));
|
||||
break;
|
||||
}
|
||||
chan[c.chan].keyOff=true;
|
||||
chan[c.chan].active=false;
|
||||
|
@ -252,7 +254,7 @@ int DivPlatformYM2610::dispatch(DivCommand c) {
|
|||
chan[c.chan].vol=c.value;
|
||||
DivInstrument* ins=parent->getIns(chan[c.chan].ins);
|
||||
if (c.chan>6) { // ADPCM
|
||||
writes.emplace(0x108+(c.chan-7),0xc0|chan[c.chan].vol);
|
||||
writes.emplace(0x108+(c.chan-7),(chan[c.chan].pan<<6)|chan[c.chan].vol);
|
||||
break;
|
||||
}
|
||||
if (c.chan>3) { // PSG
|
||||
|
@ -284,7 +286,6 @@ int DivPlatformYM2610::dispatch(DivCommand c) {
|
|||
chan[c.chan].ins=c.value;
|
||||
break;
|
||||
case DIV_CMD_PANNING: {
|
||||
if (c.chan>3) break;
|
||||
switch (c.value) {
|
||||
case 0x01:
|
||||
chan[c.chan].pan=1;
|
||||
|
@ -296,6 +297,11 @@ int DivPlatformYM2610::dispatch(DivCommand c) {
|
|||
chan[c.chan].pan=3;
|
||||
break;
|
||||
}
|
||||
if (c.chan>6) {
|
||||
writes.emplace(0x108+(c.chan-7),(chan[c.chan].pan<<6)|chan[c.chan].vol);
|
||||
break;
|
||||
}
|
||||
if (c.chan>3) break;
|
||||
DivInstrument* ins=parent->getIns(chan[c.chan].ins);
|
||||
rWrite(chanOffs[c.chan]+0xb4,(chan[c.chan].pan<<6)|(ins->fm.fms&7)|((ins->fm.ams&3)<<4));
|
||||
break;
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
uint8_t DivYM2610Interface::ymfm_external_read(ymfm::access_class type, uint32_t address) {
|
||||
//printf("wants to read from %x\n",address);
|
||||
if (type!=ymfm::ACCESS_ADPCM_A) return 0;
|
||||
if (12*sampleBank+(address>>16)>=parent->song.sampleLen) return 0;
|
||||
return parent->song.sample[12*sampleBank+(address>>16)]->adpcmRendData[(address&0xffff)];
|
||||
return parent->adpcmMem[address&0xffffff];
|
||||
/*if (12*sampleBank+(address>>16)>=parent->song.sampleLen) return 0;
|
||||
return parent->song.sample[12*sampleBank+(address>>16)]->adpcmRendData[(address&0xffff)];*/
|
||||
}
|
||||
|
||||
void DivYM2610Interface::ymfm_external_write(ymfm::access_class type, uint32_t address, uint8_t data) {
|
||||
|
|
|
@ -4,7 +4,7 @@ struct DivSample {
|
|||
signed char vol, pitch;
|
||||
unsigned char depth;
|
||||
short* data;
|
||||
int rendLength, adpcmRendLength;
|
||||
int rendLength, adpcmRendLength, rendOff;
|
||||
short* rendData;
|
||||
unsigned char* adpcmRendData;
|
||||
|
||||
|
@ -18,6 +18,7 @@ struct DivSample {
|
|||
data(NULL),
|
||||
rendLength(0),
|
||||
adpcmRendLength(0),
|
||||
rendOff(0),
|
||||
rendData(NULL),
|
||||
adpcmRendData(NULL) {}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue