MAME:减少M92的IRQ SOUND的GC

This commit is contained in:
sin365 2025-11-06 17:06:17 +08:00
parent 6be5d7dec7
commit 9e7b37a709
4 changed files with 92 additions and 48 deletions

View File

@ -78,6 +78,12 @@ namespace MAME.Core
vector = _vector; vector = _vector;
time = _time; time = _time;
} }
public vec setdata(int _vector, Atime _time)
{
vector = _vector;
time = _time;
return this;
}
} }
public class Cpuint public class Cpuint
{ {
@ -88,11 +94,29 @@ namespace MAME.Core
//public static int[, ,] input_state; //public static int[, ,] input_state;
public static List<irq> lirq; public static List<irq> lirq;
public static List<vec> lvec; public static List<vec> lvec;
static void lvec_reinit()
{
if (lvec == null)
{
lvec = ObjectPoolAuto.AcquireList<vec>();
}
else
{
for (int i = lvec.Count - 1; i >= 0; i--)
{
ObjectPoolAuto.Release(lvec[i]);
}
lvec.Clear();
}
}
public static void cpuint_init() public static void cpuint_init()
{ {
int i, j; int i, j;
lirq = new List<irq>(); lirq = new List<irq>();
lvec = new List<vec>(); //lvec = new List<vec>();
lvec_reinit();
interrupt_vector = new int[8, 35]; interrupt_vector = new int[8, 35];
input_line_state = new byte[8, 35]; input_line_state = new byte[8, 35];
input_line_vector = new int[8, 35]; input_line_vector = new int[8, 35];
@ -112,7 +136,8 @@ namespace MAME.Core
{ {
int i, j; int i, j;
lirq = new List<irq>(); lirq = new List<irq>();
lvec = new List<vec>(); //lvec = new List<vec>();
lvec_reinit();
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
{ {
for (j = 0; j < 35; j++) for (j = 0; j < 35; j++)
@ -282,10 +307,12 @@ namespace MAME.Core
{ {
int i, n; int i, n;
n = reader.ReadInt32(); n = reader.ReadInt32();
lvec = new List<vec>(); //lvec = new List<vec>();
lvec_reinit();
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
lvec.Add(new vec()); //lvec.Add(new vec());
lvec.Add(ObjectPoolAuto.Acquire<vec>());
lvec[i].vector = reader.ReadInt32(); lvec[i].vector = reader.ReadInt32();
lvec[i].time.seconds = reader.ReadInt32(); lvec[i].time.seconds = reader.ReadInt32();
lvec[i].time.attoseconds = reader.ReadInt64(); lvec[i].time.attoseconds = reader.ReadInt64();

View File

@ -44,14 +44,16 @@
{ {
if (irq != 0) if (irq != 0)
{ {
Cpuint.lvec.Add(new vec(1, EmuTimer.get_current_time())); //Cpuint.lvec.Add(new vec(1, EmuTimer.get_current_time()));
Cpuint.lvec.Add(ObjectPoolAuto.Acquire<vec>().setdata(1, EmuTimer.get_current_time()));
setvector_param = 1; setvector_param = 1;
EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true); EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true);
EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER);
} }
else else
{ {
Cpuint.lvec.Add(new vec(2, EmuTimer.get_current_time())); //Cpuint.lvec.Add(new vec(2, EmuTimer.get_current_time()));
Cpuint.lvec.Add(ObjectPoolAuto.Acquire<vec>().setdata(2, EmuTimer.get_current_time()));
setvector_param = 2; setvector_param = 2;
EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true); EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true);
EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER);
@ -62,7 +64,8 @@
//if (ACCESSING_BITS_0_7) //if (ACCESSING_BITS_0_7)
{ {
Sound.soundlatch_w(data); Sound.soundlatch_w(data);
Cpuint.lvec.Add(new vec(3, EmuTimer.get_current_time())); //Cpuint.lvec.Add(new vec(3, EmuTimer.get_current_time()));
Cpuint.lvec.Add(ObjectPoolAuto.Acquire<vec>().setdata(3, EmuTimer.get_current_time()));
setvector_param = 3; setvector_param = 3;
EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true); EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true);
EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER);
@ -71,14 +74,16 @@
public static void m72_sound_command_byte_w(int offset, byte data) public static void m72_sound_command_byte_w(int offset, byte data)
{ {
Sound.soundlatch_w(data); Sound.soundlatch_w(data);
Cpuint.lvec.Add(new vec(3, EmuTimer.get_current_time())); //Cpuint.lvec.Add(new vec(3, EmuTimer.get_current_time()));
Cpuint.lvec.Add(ObjectPoolAuto.Acquire<vec>().setdata(3, EmuTimer.get_current_time()));
setvector_param = 3; setvector_param = 3;
EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true); EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true);
EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER);
} }
public static void m72_sound_irq_ack_w(int offset, byte data) public static void m72_sound_irq_ack_w(int offset, byte data)
{ {
Cpuint.lvec.Add(new vec(4, EmuTimer.get_current_time())); //Cpuint.lvec.Add(new vec(4, EmuTimer.get_current_time()));
Cpuint.lvec.Add(ObjectPoolAuto.Acquire<vec>().setdata(4, EmuTimer.get_current_time()));
setvector_param = 4; setvector_param = 4;
EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true); EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true);
EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER);

View File

@ -468,7 +468,8 @@ namespace MAME.Core
} }
public static void setvector_callback() public static void setvector_callback()
{ {
List<vec> lsvec = new List<vec>(); List<vec> lsvec = ObjectPoolAuto.AcquireList<vec>();
//List<vec> lsvec = new List<vec>();
foreach (vec v1 in Cpuint.lvec) foreach (vec v1 in Cpuint.lvec)
{ {
if (Attotime.attotime_compare(v1.time, EmuTimer.global_basetime) < 0) if (Attotime.attotime_compare(v1.time, EmuTimer.global_basetime) < 0)
@ -485,7 +486,10 @@ namespace MAME.Core
foreach (vec v1 in lsvec) foreach (vec v1 in lsvec)
{ {
Cpuint.lvec.Remove(v1); Cpuint.lvec.Remove(v1);
ObjectPoolAuto.Release(v1);
} }
ObjectPoolAuto.Release(lsvec);
switch (setvector_param) switch (setvector_param)
{ {
case 0: case 0:
@ -523,7 +527,8 @@ namespace MAME.Core
} }
public static void m92_soundlatch_w(ushort data) public static void m92_soundlatch_w(ushort data)
{ {
Cpuint.lvec.Add(new vec(3, EmuTimer.get_current_time())); //Cpuint.lvec.Add(new vec(3, EmuTimer.get_current_time()));
Cpuint.lvec.Add(ObjectPoolAuto.Acquire<vec>().setdata(3, EmuTimer.get_current_time()));
setvector_param = 3; setvector_param = 3;
EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true); EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true);
EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER);
@ -539,7 +544,8 @@ namespace MAME.Core
} }
public static void m92_sound_irq_ack_w() public static void m92_sound_irq_ack_w()
{ {
Cpuint.lvec.Add(new vec(4, EmuTimer.get_current_time())); //Cpuint.lvec.Add(new vec(4, EmuTimer.get_current_time()));
Cpuint.lvec.Add(ObjectPoolAuto.Acquire<vec>().setdata(4, EmuTimer.get_current_time()));
setvector_param = 4; setvector_param = 4;
EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true); EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true);
EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER);
@ -553,14 +559,16 @@ namespace MAME.Core
{ {
if (state != 0) if (state != 0)
{ {
Cpuint.lvec.Add(new vec(1, EmuTimer.get_current_time())); //Cpuint.lvec.Add(new vec(1, EmuTimer.get_current_time()));
Cpuint.lvec.Add(ObjectPoolAuto.Acquire<vec>().setdata(1, EmuTimer.get_current_time()));
setvector_param = 1; setvector_param = 1;
EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true); EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true);
EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER);
} }
else else
{ {
Cpuint.lvec.Add(new vec(2, EmuTimer.get_current_time())); //Cpuint.lvec.Add(new vec(2, EmuTimer.get_current_time()));
Cpuint.lvec.Add(ObjectPoolAuto.Acquire<vec>().setdata(2, EmuTimer.get_current_time()));
setvector_param = 2; setvector_param = 2;
EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true); EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true);
EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER);

View File

@ -23,54 +23,58 @@ namespace MAME.Core
}; };
public static IremGA20_chip_def chip; public static IremGA20_chip_def chip;
public static byte[] iremrom; public static byte[] iremrom;
static int[] update_rate = new int[4], update_pos = new int[4], update_frac = new int[4], update_end = new int[4], update_vol = new int[4], update_play = new int[4];
public static void iremga20_update(int offset, int length) public static void iremga20_update(int offset, int length)
{ {
int[] rate = new int[4], pos = new int[4], frac = new int[4], end = new int[4], vol = new int[4], play = new int[4]; //int[] rate = new int[4], pos = new int[4], frac = new int[4], end = new int[4], vol = new int[4], play = new int[4];
int i, sampleout; int i, sampleout;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
rate[i] = chip.channel[i].rate; update_rate[i] = chip.channel[i].rate;
pos[i] = chip.channel[i].pos; update_pos[i] = chip.channel[i].pos;
frac[i] = chip.channel[i].frac; update_frac[i] = chip.channel[i].frac;
end[i] = chip.channel[i].end - 0x20; update_end[i] = chip.channel[i].end - 0x20;
vol[i] = chip.channel[i].volume; update_vol[i] = chip.channel[i].volume;
play[i] = chip.channel[i].play; update_play[i] = chip.channel[i].play;
} }
i = length; i = length;
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
sampleout = 0; sampleout = 0;
if (play[0] != 0) if (update_play[0] != 0)
{ {
sampleout += (iremrom[pos[0]] - 0x80) * vol[0]; sampleout += (iremrom[update_pos[0]] - 0x80) * update_vol[0];
frac[0] += rate[0]; update_frac[0] += update_rate[0];
pos[0] += frac[0] >> 24; update_pos[0] += update_frac[0] >> 24;
frac[0] &= 0xffffff; update_frac[0] &= 0xffffff;
play[0] = pos[0] < end[0] ? 1 : 0; update_play[0] = update_pos[0] < update_end[0] ? 1 : 0;
} }
if (play[1] != 0) if (update_play[1] != 0)
{ {
sampleout += (iremrom[pos[1]] - 0x80) * vol[1]; sampleout += (iremrom[update_pos[1]] - 0x80) * update_vol[1];
frac[1] += rate[1]; update_frac[1] += update_rate[1];
pos[1] += frac[1] >> 24; update_pos[1] += update_frac[1] >> 24;
frac[1] &= 0xffffff; update_frac[1] &= 0xffffff;
play[1] = pos[1] < end[1] ? 1 : 0; update_play[1] = update_pos[1] < update_end[1] ? 1 : 0;
} }
if (play[2] != 0) if (update_play[2] != 0)
{ {
sampleout += (iremrom[pos[2]] - 0x80) * vol[2]; sampleout += (iremrom[update_pos[2]] - 0x80) * update_vol[2];
frac[2] += rate[2]; update_frac[2] += update_rate[2];
pos[2] += frac[2] >> 24; update_pos[2] += update_frac[2] >> 24;
frac[2] &= 0xffffff; update_frac[2] &= 0xffffff;
play[2] = pos[2] < end[2] ? 1 : 0; update_play[2] = update_pos[2] < update_end[2] ? 1 : 0;
} }
if (play[3] != 0) if (update_play[3] != 0)
{ {
sampleout += (iremrom[pos[3]] - 0x80) * vol[3]; sampleout += (iremrom[update_pos[3]] - 0x80) * update_vol[3];
frac[3] += rate[3]; update_frac[3] += update_rate[3];
pos[3] += frac[3] >> 24; update_pos[3] += update_frac[3] >> 24;
frac[3] &= 0xffffff; update_frac[3] &= 0xffffff;
play[3] = pos[3] < end[3] ? 1 : 0; update_play[3] = update_pos[3] < update_end[3] ? 1 : 0;
} }
sampleout >>= 2; sampleout >>= 2;
Sound.iremga20stream.streamoutput_Ptrs[0][offset + i] = sampleout; Sound.iremga20stream.streamoutput_Ptrs[0][offset + i] = sampleout;
@ -78,9 +82,9 @@ namespace MAME.Core
} }
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
chip.channel[i].pos = pos[i]; chip.channel[i].pos = update_pos[i];
chip.channel[i].frac = frac[i]; chip.channel[i].frac = update_frac[i];
chip.channel[i].play = play[i]; chip.channel[i].play = update_play[i];
} }
} }
public static void irem_ga20_w(int offset, ushort data) public static void irem_ga20_w(int offset, ushort data)