OPL: possibly implement drums mode
we need a good UI for it
This commit is contained in:
parent
d09aa778d9
commit
e7f6290012
|
@ -48,6 +48,10 @@ const unsigned short chanMapOPL2[20]={
|
||||||
0, 1, 2, 3, 4, 5, 6, 7, 8, N, N, N, N, N, N, N, N, N, N, N
|
0, 1, 2, 3, 4, 5, 6, 7, 8, N, N, N, N, N, N, N, N, N, N, N
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const unsigned short chanMapOPL2Drums[20]={
|
||||||
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 7, N, N, N, N, N, N, N, N, N
|
||||||
|
};
|
||||||
|
|
||||||
const unsigned char* slotsOPL2[4]={
|
const unsigned char* slotsOPL2[4]={
|
||||||
slotsOPL2i[0],
|
slotsOPL2i[0],
|
||||||
slotsOPL2i[1],
|
slotsOPL2i[1],
|
||||||
|
@ -80,6 +84,10 @@ const unsigned short chanMapOPL3[20]={
|
||||||
0, 3, 1, 4, 2, 5, 0x100, 0x103, 0x101, 0x104, 0x102, 0x105, 0x106, 0x107, 0x108, 6, 7, 8, N, N
|
0, 3, 1, 4, 2, 5, 0x100, 0x103, 0x101, 0x104, 0x102, 0x105, 0x106, 0x107, 0x108, 6, 7, 8, N, N
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const unsigned short chanMapOPL3Drums[20]={
|
||||||
|
0, 3, 1, 4, 2, 5, 0x100, 0x103, 0x101, 0x104, 0x102, 0x105, 0x106, 0x107, 0x108, 6, 7, 8, 8, 7
|
||||||
|
};
|
||||||
|
|
||||||
const unsigned char* slotsOPL3[4]={
|
const unsigned char* slotsOPL3[4]={
|
||||||
slotsOPL3i[0],
|
slotsOPL3i[0],
|
||||||
slotsOPL3i[1],
|
slotsOPL3i[1],
|
||||||
|
@ -224,7 +232,7 @@ void DivPlatformOPL::acquire(short* bufL, short* bufR, size_t start, size_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformOPL::tick() {
|
void DivPlatformOPL::tick() {
|
||||||
for (int i=0; i<melodicChans; i++) {
|
for (int i=0; i<totalChans; i++) {
|
||||||
int ops=(slots[3][i]!=255 && chan[i].state.ops==4 && oplType==3)?4:2;
|
int ops=(slots[3][i]!=255 && chan[i].state.ops==4 && oplType==3)?4:2;
|
||||||
chan[i].std.next();
|
chan[i].std.next();
|
||||||
|
|
||||||
|
@ -266,7 +274,6 @@ void DivPlatformOPL::tick() {
|
||||||
|
|
||||||
if (chan[i].std.hadAlg) {
|
if (chan[i].std.hadAlg) {
|
||||||
chan[i].state.alg=chan[i].std.alg;
|
chan[i].state.alg=chan[i].std.alg;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (chan[i].std.hadFb) {
|
if (chan[i].std.hadFb) {
|
||||||
chan[i].state.fb=chan[i].std.fb;
|
chan[i].state.fb=chan[i].std.fb;
|
||||||
|
@ -356,11 +363,13 @@ void DivPlatformOPL::tick() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i<melodicChans) {
|
||||||
if (chan[i].keyOn || chan[i].keyOff) {
|
if (chan[i].keyOn || chan[i].keyOff) {
|
||||||
immWrite(chanMap[i]+ADDR_FREQH,0x00|(chan[i].freqH&31));
|
immWrite(chanMap[i]+ADDR_FREQH,0x00|(chan[i].freqH&31));
|
||||||
chan[i].keyOff=false;
|
chan[i].keyOff=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (update4OpMask) {
|
if (update4OpMask) {
|
||||||
update4OpMask=false;
|
update4OpMask=false;
|
||||||
|
@ -371,6 +380,22 @@ void DivPlatformOPL::tick() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update drums
|
||||||
|
if (properDrums) {
|
||||||
|
bool updateDrums=false;
|
||||||
|
for (int i=melodicChans; i<totalChans; i++) {
|
||||||
|
if (chan[i].keyOn || chan[i].keyOff) {
|
||||||
|
drumState&=~(1<<(totalChans-i-1));
|
||||||
|
updateDrums=true;
|
||||||
|
chan[i].keyOff=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updateDrums) {
|
||||||
|
immWrite(0xbd,(dam<<7)|(dvb<<6)|(properDrums<<5)|drumState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i=0; i<512; i++) {
|
for (int i=0; i<512; i++) {
|
||||||
if (pendingWrites[i]!=oldWrites[i]) {
|
if (pendingWrites[i]!=oldWrites[i]) {
|
||||||
immWrite(i,pendingWrites[i]&0xff);
|
immWrite(i,pendingWrites[i]&0xff);
|
||||||
|
@ -378,7 +403,8 @@ void DivPlatformOPL::tick() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<melodicChans; i++) {
|
bool updateDrums=false;
|
||||||
|
for (int i=0; i<totalChans; i++) {
|
||||||
if (chan[i].freqChanged) {
|
if (chan[i].freqChanged) {
|
||||||
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,octave(chan[i].baseFreq));
|
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,octave(chan[i].baseFreq));
|
||||||
if (chan[i].freq>131071) chan[i].freq=131071;
|
if (chan[i].freq>131071) chan[i].freq=131071;
|
||||||
|
@ -387,14 +413,29 @@ void DivPlatformOPL::tick() {
|
||||||
chan[i].freqL=freqt&0xff;
|
chan[i].freqL=freqt&0xff;
|
||||||
immWrite(chanMap[i]+ADDR_FREQ,chan[i].freqL);
|
immWrite(chanMap[i]+ADDR_FREQ,chan[i].freqL);
|
||||||
}
|
}
|
||||||
|
if (i<melodicChans) {
|
||||||
if (chan[i].keyOn) {
|
if (chan[i].keyOn) {
|
||||||
immWrite(chanMap[i]+ADDR_FREQH,chan[i].freqH|(0x20));
|
immWrite(chanMap[i]+ADDR_FREQH,chan[i].freqH|(0x20));
|
||||||
chan[i].keyOn=false;
|
chan[i].keyOn=false;
|
||||||
} else if (chan[i].freqChanged) {
|
} else if (chan[i].freqChanged) {
|
||||||
immWrite(chanMap[i]+ADDR_FREQH,chan[i].freqH|(chan[i].active<<5));
|
immWrite(chanMap[i]+ADDR_FREQH,chan[i].freqH|(chan[i].active<<5));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (chan[i].keyOn) {
|
||||||
|
immWrite(chanMap[i]+ADDR_FREQH,chan[i].freqH);
|
||||||
|
drumState|=(1<<(totalChans-i-1));
|
||||||
|
updateDrums=true;
|
||||||
|
chan[i].keyOn=false;
|
||||||
|
} else if (chan[i].freqChanged) {
|
||||||
|
immWrite(chanMap[i]+ADDR_FREQH,chan[i].freqH);
|
||||||
|
}
|
||||||
|
}
|
||||||
chan[i].freqChanged=false;
|
chan[i].freqChanged=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (updateDrums) {
|
||||||
|
immWrite(0xbd,(dam<<7)|(dvb<<6)|(properDrums<<5)|drumState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define OPLL_C_NUM 686
|
#define OPLL_C_NUM 686
|
||||||
|
@ -476,8 +517,7 @@ void DivPlatformOPL::muteChannel(int ch, bool mute) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int DivPlatformOPL::dispatch(DivCommand c) {
|
int DivPlatformOPL::dispatch(DivCommand c) {
|
||||||
// TODO: drums mode!
|
if (c.chan>=totalChans) return 0;
|
||||||
if (c.chan>=melodicChans) return 0;
|
|
||||||
// ineffective in 4-op mode
|
// ineffective in 4-op mode
|
||||||
if (oplType==3 && c.chan<14 && (c.chan&1) && c.cmd!=DIV_CMD_GET_VOLMAX && c.cmd!=DIV_ALWAYS_SET_VOLUME) {
|
if (oplType==3 && c.chan<14 && (c.chan&1) && c.cmd!=DIV_CMD_GET_VOLMAX && c.cmd!=DIV_ALWAYS_SET_VOLUME) {
|
||||||
if (chan[c.chan-1].fourOp) return 0;
|
if (chan[c.chan-1].fourOp) return 0;
|
||||||
|
@ -879,6 +919,8 @@ void DivPlatformOPL::reset() {
|
||||||
dam=false;
|
dam=false;
|
||||||
dvb=false;
|
dvb=false;
|
||||||
delay=0;
|
delay=0;
|
||||||
|
|
||||||
|
immWrite(0xbd,(dam<<7)|(dvb<<6)|(properDrums<<5)|drumState);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DivPlatformOPL::isStereo() {
|
bool DivPlatformOPL::isStereo() {
|
||||||
|
@ -927,7 +969,7 @@ void DivPlatformOPL::setOPLType(int type, bool drums) {
|
||||||
slotsNonDrums=slotsOPL2;
|
slotsNonDrums=slotsOPL2;
|
||||||
slotsDrums=slotsOPL2Drums;
|
slotsDrums=slotsOPL2Drums;
|
||||||
slots=drums?slotsDrums:slotsNonDrums;
|
slots=drums?slotsDrums:slotsNonDrums;
|
||||||
chanMap=chanMapOPL2;
|
chanMap=drums?chanMapOPL2Drums:chanMapOPL2;
|
||||||
chipFreqBase=9440540*0.25;
|
chipFreqBase=9440540*0.25;
|
||||||
chans=9;
|
chans=9;
|
||||||
melodicChans=drums?6:9;
|
melodicChans=drums?6:9;
|
||||||
|
@ -937,7 +979,7 @@ void DivPlatformOPL::setOPLType(int type, bool drums) {
|
||||||
slotsNonDrums=slotsOPL3;
|
slotsNonDrums=slotsOPL3;
|
||||||
slotsDrums=slotsOPL3Drums;
|
slotsDrums=slotsOPL3Drums;
|
||||||
slots=drums?slotsDrums:slotsNonDrums;
|
slots=drums?slotsDrums:slotsNonDrums;
|
||||||
chanMap=chanMapOPL3;
|
chanMap=drums?chanMapOPL3Drums:chanMapOPL3;
|
||||||
chipFreqBase=9440540;
|
chipFreqBase=9440540;
|
||||||
chans=18;
|
chans=18;
|
||||||
melodicChans=drums?15:18;
|
melodicChans=drums?15:18;
|
||||||
|
|
Loading…
Reference in a new issue