diff --git a/client/src/main/java/client/audio/OPLChip.java b/client/src/main/java/client/audio/OPLChip.java index 0d1c1ef5..c7cddf27 100644 --- a/client/src/main/java/client/audio/OPLChip.java +++ b/client/src/main/java/client/audio/OPLChip.java @@ -25,8 +25,8 @@ public class OPLChip { public ModGen mod; public int fb; public short prout; - public short eg_rout; - public short eg_out; + public int eg_rout; + public int eg_out; public EnvState eg_gen; public int eg_ksl; public ModGen trem; @@ -90,15 +90,14 @@ public class OPLChip { int reg_rate = 0; int ks; int eg_shift, shift; - short eg_rout; - short eg_inc; + int eg_rout; + int eg_inc; boolean eg_off; boolean reset = false; if(this.retrigger) { this.eg_rout = 0x1ff; } - this.eg_out = (short)(this.eg_rout + (this.reg_tl << 2) - + (this.eg_ksl >> KSL_SHIFT[this.reg_ksl]) + this.trem.getModulation()); + this.eg_out = this.eg_rout + (this.reg_tl << 2) + (this.eg_ksl >> KSL_SHIFT[this.reg_ksl]) + this.trem.getModulation(); if (this.key && this.eg_gen == EnvState.RELEASE) { reset = true; @@ -198,7 +197,7 @@ public class OPLChip { } 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; case DECAY: @@ -208,18 +207,18 @@ public class OPLChip { } else if (!eg_off && !reset && shift > 0) { - eg_inc = (short)(1 << (shift - 1)); + eg_inc = 1 << (shift - 1); } break; case SUSTAIN: case RELEASE: if (!eg_off && !reset && shift > 0) { - eg_inc = (short)(1 << (shift - 1)); + eg_inc = 1 << (shift - 1); } break; } - this.eg_rout = (short)((eg_rout + eg_inc) & 0x1ff); + this.eg_rout = (eg_rout + eg_inc) & 0x1ff; /* Key off */ if (reset) {