THIS CRASHES

This commit is contained in:
tildearrow 2023-08-21 17:24:41 -05:00
parent 18dc353392
commit 617ee5e324
2 changed files with 62 additions and 2 deletions

View File

@ -33,7 +33,7 @@
OPN2_Write((ym3438_t*)fmPreviewOPN,1,(val)); \
do { \
OPN2_Clock((ym3438_t*)fmPreviewOPN,out); \
} while (((ym3438_t*)fmPreviewOPN)->write_busy); \
} while (((ym3438_t*)fmPreviewOPN)->write_busy);
const unsigned char dtTableFMP[8]={
7,6,5,0,1,2,3,4
@ -48,7 +48,7 @@ void FurnaceGUI::renderFMPreviewOPN(const DivInstrumentFM& params, int pos) {
bool mult0=false;
if (pos==0) {
OPN2_Reset((ym3438_t*)fmPreviewOPN);
OPN2_Reset((ym3438_t*)fmPreviewOPN);
OPN2_SetChipType((ym3438_t*)fmPreviewOPN,ym3438_mode_opn);
// set params
@ -89,7 +89,62 @@ void FurnaceGUI::renderFMPreviewOPN(const DivInstrumentFM& params, int pos) {
}
}
#define OPM_WRITE(addr,val) \
OPM_Write((opm_t*)fmPreviewOPM,0,(addr)); \
do { \
OPM_Clock((opm_t*)fmPreviewOPM,out,NULL,NULL,NULL); \
} while (((opm_t*)fmPreviewOPM)->write_busy); \
OPM_Write((opm_t*)fmPreviewOPM,1,(val)); \
do { \
OPM_Clock((opm_t*)fmPreviewOPM,out,NULL,NULL,NULL); \
} while (((opm_t*)fmPreviewOPM)->write_busy);
void FurnaceGUI::renderFMPreviewOPM(const DivInstrumentFM& params, int pos) {
if (fmPreviewOPM==NULL) {
fmPreviewOPM=new opm_t;
}
int out[2];
int aOut=0;
bool mult0=false;
if (pos==0) {
OPM_Reset((opm_t*)fmPreviewOPM);
// set params
for (int i=0; i<4; i++) {
if ((params.op[i].mult&15)==0) {
mult0=true;
break;
}
}
for (int i=0; i<4; i++) {
const DivInstrumentFM::Operator& op=params.op[i];
unsigned short baseAddr=i*8;
OPM_WRITE(baseAddr+0x40,(op.mult&15)|(dtTableFMP[op.dt&7]<<4));
OPM_WRITE(baseAddr+0x60,op.tl);
OPM_WRITE(baseAddr+0x80,(op.ar&31)|(op.rs<<6));
OPM_WRITE(baseAddr+0xa0,(op.dr&31)|(op.am<<7));
OPM_WRITE(baseAddr+0xc0,(op.d2r&31)|(op.dt2<<6));
OPM_WRITE(baseAddr+0xe0,(op.rr&15)|(op.sl<<4));
}
OPM_WRITE(0x20,(params.alg&7)|((params.fb&7)<<3)|0xc0);
OPM_WRITE(0x38,((params.fms&7)<<4)|(params.ams&3));
OPM_WRITE(0x28,mult0?0x00:0x10); // frequency
OPM_WRITE(0x30,0);
OPM_WRITE(0x08,0x78); // key on
}
// render
for (int i=0; i<FM_PREVIEW_SIZE; i++) {
aOut=0;
for (int j=0; j<24; j++) {
OPM_Clock((opm_t*)fmPreviewOPM,out,NULL,NULL,NULL);
}
aOut+=((opm_t*)fmPreviewOPM)->ch_out[0];
if (aOut<-32768) aOut=-32768;
if (aOut>32767) aOut=32767;
fmPreview[i]=aOut;
}
}
void FurnaceGUI::renderFMPreviewOPLL(const DivInstrumentFM& params, int pos) {

View File

@ -19,6 +19,7 @@
#define _USE_MATH_DEFINES
#include "gui.h"
#include "../ta-log.h"
#include "imgui_internal.h"
#include "../engine/macroInt.h"
#include "IconsFontAwesome4.h"
@ -1302,6 +1303,10 @@ void FurnaceGUI::kvsConfig(DivInstrument* ins) {
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
fmPreviewOn=!fmPreviewOn;
}
if (ImGui::IsItemHovered() && CHECK_LONG_HOLD) {
NOTIFY_LONG_HOLD;
fmPreviewOn=!fmPreviewOn;
}
if (!fmPreviewOn) {
int opCount=4;
if (ins->type==DIV_INS_OPLL) opCount=2;