diff --git a/src/gui/fmPreview.cpp b/src/gui/fmPreview.cpp index d18f96c4..b8359312 100644 --- a/src/gui/fmPreview.cpp +++ b/src/gui/fmPreview.cpp @@ -212,7 +212,74 @@ void FurnaceGUI::renderFMPreviewOPLL(const DivInstrumentFM& params, int pos) { } } +#define OPL_WRITE(addr,val) \ + OPL3_WriteReg((opl3_chip*)fmPreviewOPL,(addr),(val)); \ + OPL3_Generate4Ch((opl3_chip*)fmPreviewOPL,out); + +const unsigned char lPreviewSlots[4]={ + 0, 3, 8, 11 +}; + +const unsigned char lOpMap[4]={ + 0, 2, 1, 3 +}; + void FurnaceGUI::renderFMPreviewOPL(const DivInstrumentFM& params, int pos) { + if (fmPreviewOPL==NULL) { + fmPreviewOPL=new opl3_chip; + pos=0; + } + short out[4]; + bool mult0=false; + + if (pos==0) { + OPL3_Reset((opl3_chip*)fmPreviewOPL,49716); + + // set params + int ops=(params.ops==4)?4:2; + for (int i=0; i>1)&1)|(params.fb<<1)|0x10); + } + OPL_WRITE(0xa0,0); + if (ops==4) { + OPL_WRITE(0xa3,0); + } + OPL_WRITE(0xb0,mult0?0x2a:0x26); + if (ops==4) { + OPL_WRITE(0xb3,mult0?0x2a:0x26); + } + } + + // render + for (int i=0; i