1
0
Fork 0

opl types update 4 (fixed?)

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

View file

@ -28,18 +28,18 @@ public class OPLChip {
public short eg_rout;
public short eg_out;
public EnvState eg_gen;
public byte eg_ksl;
public int eg_ksl;
public ModGen trem;
public boolean reg_vib;
public boolean reg_type;
public boolean reg_ksr;
public byte reg_mult;
public byte reg_ksl;
public byte reg_tl;
public byte reg_ar;
public byte reg_dr;
public byte reg_sl;
public byte reg_rr;
public int reg_mult;
public int reg_ksl;
public int reg_tl;
public int reg_ar;
public int reg_dr;
public int reg_sl;
public int reg_rr;
public int reg_wf;
public boolean key;
public boolean detrigger;
@ -84,12 +84,12 @@ public class OPLChip {
this.prout = this.out;
// envelope
boolean nonzero;
byte rate;
byte rate_hi;
byte rate_lo;
byte reg_rate = 0;
byte ks;
byte eg_shift, shift;
int rate;
int rate_hi;
int rate_lo;
int reg_rate = 0;
int ks;
int eg_shift, shift;
short eg_rout;
short eg_inc;
boolean eg_off;
@ -126,16 +126,16 @@ public class OPLChip {
}
}
this.pg_reset = reset;
ks = (byte)(this.ksv >> (this.reg_ksr ? 0 : 2));
ks = this.ksv >> (this.reg_ksr ? 0 : 2);
nonzero = (reg_rate != 0);
rate = (byte)(ks + (reg_rate << 2));
rate_hi = (byte)(rate >> 2);
rate_lo = (byte)(rate & 0x03);
rate = ks + (reg_rate << 2);
rate_hi = rate >> 2;
rate_lo = rate & 0x03;
if ((rate_hi & 0x10) != 0)
{
rate_hi = 0x0f;
}
eg_shift = (byte)(rate_hi + OPLChip.this.eg_add);
eg_shift = rate_hi + OPLChip.this.eg_add;
shift = 0;
if (nonzero)
{
@ -149,10 +149,10 @@ public class OPLChip {
shift = 1;
break;
case 13:
shift = (byte)((rate_lo >> 1) & 0x01);
shift = (rate_lo >> 1) & 0x01;
break;
case 14:
shift = (byte)(rate_lo & 0x01);
shift = rate_lo & 0x01;
break;
default:
break;
@ -161,14 +161,14 @@ public class OPLChip {
}
else
{
shift = (byte)((rate_hi & 0x03) + EG_INC[rate_lo][OPLChip.this.timer & 0x03]);
shift = (rate_hi & 0x03) + EG_INC[rate_lo][OPLChip.this.timer & 0x03];
if ((shift & 0x04) != 0)
{
shift = 0x03;
}
if (shift == 0)
{
shift = (byte)(OPLChip.this.eg_state ? 1 : 0);
shift = OPLChip.this.eg_state ? 1 : 0;
}
}
}
@ -253,7 +253,7 @@ public class OPLChip {
range >>= OPLChip.this.vibshift;
if ((vibpos & 4) != 0)
{
range = (byte)-range;
range = -range;
}
f_num += range;
}
@ -269,13 +269,12 @@ public class OPLChip {
private void updateKSL()
{
short ksl = (short)((KSL[this.f_num >> 6] << 2)
- ((0x08 - this.block) << 5));
int ksl = (KSL[this.f_num >> 6] << 2) - ((0x08 - this.block) << 5);
if (ksl < 0)
{
ksl = 0;
}
this.eg_ksl = (byte)ksl;
this.eg_ksl = ksl;
}
private void keyOn()
@ -309,27 +308,27 @@ public class OPLChip {
}
public void setMultiplier(int mult) {
this.reg_mult = (byte)(mult & 0x0f);
this.reg_mult = mult;
}
public void setKSL(int ksl) {
this.reg_ksl = (byte)(ksl & 0x03);
this.reg_ksl = ksl;
this.updateKSL();
}
public void setLevel(int level) {
this.reg_tl = (byte)(level & 0x3f);
this.reg_tl = level;
}
public void setEnvelope(int attack, int decay, int sustain, int release) {
this.reg_ar = (byte)(attack & 0x0f);
this.reg_dr = (byte)(decay & 0x0f);
this.reg_sl = (byte)(sustain & 0x0f);
this.reg_ar = attack;
this.reg_dr = decay;
this.reg_sl = sustain;
if (this.reg_sl == 0x0f)
{
this.reg_sl = 0x1f;
}
this.reg_rr = (byte)(release & 0x0f);
this.reg_rr = release;
if (this.reg_rr == 0x00)
{
this.reg_rr = 0x01;
@ -337,7 +336,7 @@ public class OPLChip {
}
public void setWaveform(int waveform) {
this.reg_wf = (byte)(waveform & 0x07);
this.reg_wf = waveform;
}
private void updateFrequency() {
@ -626,15 +625,15 @@ public class OPLChip {
1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 20, 24, 24, 30, 30
};
private static final byte[] KSL = {
private static final int[] KSL = {
0, 32, 40, 45, 48, 51, 53, 55, 56, 58, 59, 60, 61, 62, 63, 64
};
private static final byte[] KSL_SHIFT = {
private static final int[] KSL_SHIFT = {
8, 1, 2, 0
};
private static final byte[][] EG_INC = {
private static final int[][] EG_INC = {
{ 0, 0, 0, 0 },
{ 1, 0, 0, 0 },
{ 1, 0, 1, 0 },
@ -906,7 +905,7 @@ public class OPLChip {
this.eg_add = 0;
if (this.eg_timer != 0)
{
byte shift = 0;
int shift = 0;
while (shift < 36 && ((this.eg_timer >> shift) & 1L) == 0L)
{
shift++;