1
0
Fork 0

opl types update 5 (fixed!)

This commit is contained in:
Sen 2025-08-25 14:58:40 +02:00
parent 54247c848b
commit b100930722
Signed by: sen
GPG key ID: 3AC50A6F47D1B722

View file

@ -25,8 +25,8 @@ public class OPLChip {
public ModGen mod; public ModGen mod;
public int fb; public int fb;
public short prout; public short prout;
public short eg_rout; public int eg_rout;
public short eg_out; public int eg_out;
public EnvState eg_gen; public EnvState eg_gen;
public int eg_ksl; public int eg_ksl;
public ModGen trem; public ModGen trem;
@ -90,15 +90,14 @@ public class OPLChip {
int reg_rate = 0; int reg_rate = 0;
int ks; int ks;
int eg_shift, shift; int eg_shift, shift;
short eg_rout; int eg_rout;
short eg_inc; int eg_inc;
boolean eg_off; boolean eg_off;
boolean reset = false; boolean reset = false;
if(this.retrigger) { if(this.retrigger) {
this.eg_rout = 0x1ff; this.eg_rout = 0x1ff;
} }
this.eg_out = (short)(this.eg_rout + (this.reg_tl << 2) this.eg_out = this.eg_rout + (this.reg_tl << 2) + (this.eg_ksl >> KSL_SHIFT[this.reg_ksl]) + this.trem.getModulation();
+ (this.eg_ksl >> KSL_SHIFT[this.reg_ksl]) + this.trem.getModulation());
if (this.key && this.eg_gen == EnvState.RELEASE) if (this.key && this.eg_gen == EnvState.RELEASE)
{ {
reset = true; reset = true;
@ -198,7 +197,7 @@ public class OPLChip {
} }
else if (this.key && shift > 0 && rate_hi != 0x0f) else if (this.key && shift > 0 && rate_hi != 0x0f)
{ {
eg_inc = (short)(~this.eg_rout >> (4 - shift)); eg_inc = ((~this.eg_rout) & 0xffff) >> (4 - shift);
} }
break; break;
case DECAY: case DECAY:
@ -208,18 +207,18 @@ public class OPLChip {
} }
else if (!eg_off && !reset && shift > 0) else if (!eg_off && !reset && shift > 0)
{ {
eg_inc = (short)(1 << (shift - 1)); eg_inc = 1 << (shift - 1);
} }
break; break;
case SUSTAIN: case SUSTAIN:
case RELEASE: case RELEASE:
if (!eg_off && !reset && shift > 0) if (!eg_off && !reset && shift > 0)
{ {
eg_inc = (short)(1 << (shift - 1)); eg_inc = 1 << (shift - 1);
} }
break; break;
} }
this.eg_rout = (short)((eg_rout + eg_inc) & 0x1ff); this.eg_rout = (eg_rout + eg_inc) & 0x1ff;
/* Key off */ /* Key off */
if (reset) if (reset)
{ {