Compare commits
2 Commits
6edb3b5400
...
e41c910496
| Author | SHA1 | Date | |
|---|---|---|---|
| e41c910496 | |||
| e394d38e27 |
@ -123,7 +123,7 @@ namespace MAME.Core
|
||||
|
||||
public EmuTimerLister()
|
||||
{
|
||||
capacity = 32;
|
||||
capacity = 16;
|
||||
timerArray = new emu_timer[capacity];
|
||||
Count = 0;
|
||||
_frist_Timer = null;
|
||||
@ -303,7 +303,6 @@ namespace MAME.Core
|
||||
|
||||
static Queue<emu_timer> _readyToRelease = new Queue<emu_timer>();
|
||||
static Queue<emu_timer> _timerPool = new Queue<emu_timer>();
|
||||
|
||||
static int outTimerAllCount = 0;
|
||||
static int newTimerCount = 0;
|
||||
public static emu_timer GetEmu_timerNoRef()
|
||||
@ -321,7 +320,6 @@ namespace MAME.Core
|
||||
outTimerAllCount++;
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static void CheckReadyRelaseBeforeFrameRun()
|
||||
{
|
||||
if (_readyToRelease.Count < 1)
|
||||
@ -341,10 +339,7 @@ namespace MAME.Core
|
||||
//UnityEngine.Debug.Log($"CheckReadyRelaseAfterRun 检查数量{checkcount}| 出池数量{outTimerAllCount},其中new创建的数量{newTimerCount} 回收数量{releaseCount} ,处理前池数量{beforpoolcount},处理后池数量{_timerPool.Count}");
|
||||
outTimerAllCount = 0;
|
||||
newTimerCount = 0;
|
||||
//_readyToRelease.Clear();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 增加引用计数
|
||||
/// </summary>
|
||||
@ -353,7 +348,6 @@ namespace MAME.Core
|
||||
//int newCount = Interlocked.Increment(ref _refCount);
|
||||
_refCount++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 减少引用计数,当计数为0时释放对象回池
|
||||
/// </summary>
|
||||
@ -372,7 +366,6 @@ namespace MAME.Core
|
||||
throw new InvalidOperationException("引用计数出现负数");
|
||||
}
|
||||
}
|
||||
|
||||
void ReadyToRelease()
|
||||
{
|
||||
if (this._inReadyQueue) return;
|
||||
@ -380,7 +373,6 @@ namespace MAME.Core
|
||||
this._inReadyQueue = true;
|
||||
_readyToRelease.Enqueue(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源并回池
|
||||
/// </summary>
|
||||
@ -1119,20 +1111,10 @@ namespace MAME.Core
|
||||
{
|
||||
TIME_ACT currAct = timer1.action;
|
||||
int i1 = -1;
|
||||
//var tlist = lt.GetSnapshotList();
|
||||
int scanCount;
|
||||
int tempMaxIdx = lt.Count - 1;
|
||||
if (currAct == TIME_ACT.Cpuint_cpunum_empty_event_queue || currAct == TIME_ACT.setvector)
|
||||
{
|
||||
//foreach (emu_timer et in lt)
|
||||
//foreach (emu_timer et in lt.GetSrcList())
|
||||
//{
|
||||
// if (et.action == currAct && Attotime.attotime_compare(et.expire, global_basetime) <= 0)
|
||||
// {
|
||||
// i1 = lt.IndexOf(et);
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
scanCount = 0;
|
||||
while (scanCount >= tempMaxIdx)
|
||||
{
|
||||
@ -1210,39 +1192,19 @@ namespace MAME.Core
|
||||
{
|
||||
if (timer1.action == TIME_ACT.Cpuint_cpunum_empty_event_queue || timer1.action == TIME_ACT.setvector)
|
||||
{
|
||||
//timer_list_remove_lt1.Clear();
|
||||
//foreach (emu_timer et in lt.GetSrcList())
|
||||
//{
|
||||
// if (et.action == timer1.action && Attotime.attotime_compare(et.expire, timer1.expire) == 0)
|
||||
// timer_list_remove_lt1.Add(et);
|
||||
//}
|
||||
//foreach (emu_timer et1 in timer_list_remove_lt1)
|
||||
// lt.Remove(et1);
|
||||
|
||||
//var tlist = lt.GetSnapshotList();
|
||||
int tempMaxIdx = lt.Count - 1;
|
||||
while (tempMaxIdx >= 0)
|
||||
{
|
||||
emu_timer et = lt[tempMaxIdx];
|
||||
if (et.action == timer1.action && Attotime.attotime_compare(et.expire, timer1.expire) == 0)
|
||||
lt.Remove(et);
|
||||
{
|
||||
lt.RemoveAt(tempMaxIdx);
|
||||
}
|
||||
tempMaxIdx--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO MAME.NET原来这么foreach写删除是有问题的
|
||||
//foreach (emu_timer et in lt)
|
||||
//foreach (emu_timer et in lt.GetSrcList())
|
||||
//{
|
||||
// if (et.action == timer1.action)
|
||||
// {
|
||||
// lt.Remove(et);
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
//var tlist = lt.GetSnapshotList();
|
||||
int tempMaxIdx = lt.Count - 1;
|
||||
int scanCount = 0;
|
||||
while (scanCount <= tempMaxIdx)
|
||||
@ -1250,7 +1212,7 @@ namespace MAME.Core
|
||||
emu_timer et = lt[scanCount];
|
||||
if (et.action == timer1.action)
|
||||
{
|
||||
lt.Remove(et);
|
||||
lt.RemoveAt(scanCount);
|
||||
break;
|
||||
}
|
||||
scanCount++;
|
||||
@ -1334,6 +1296,7 @@ namespace MAME.Core
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//public static emu_timer timer_alloc_common(TIME_ACT action, bool temp)
|
||||
//{
|
||||
// Atime time = get_current_time();
|
||||
@ -1358,16 +1321,6 @@ namespace MAME.Core
|
||||
/// <param name="temp"></param>
|
||||
public static void timer_alloc_common(ref emu_timer refattr, TIME_ACT action, bool temp)
|
||||
{
|
||||
//Atime time = get_current_time();
|
||||
//emu_timer timer = emu_timer.GetEmu_timerNoRef();
|
||||
//timer.action = action;
|
||||
//timer.enabled = false;
|
||||
//timer.temporary = temp;
|
||||
//timer.period = Attotime.ATTOTIME_ZERO;
|
||||
////timer.func = func;
|
||||
//timer.start = time;
|
||||
//timer.expire = Attotime.ATTOTIME_NEVER;
|
||||
//timer_list_insert(timer);
|
||||
emu_timer timer = timer_alloc_common_NoRef(action, temp);
|
||||
emu_timer.SetRefUsed(ref refattr, ref timer);
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using NUnit;
|
||||
using System;
|
||||
using static MAME.Core.EmuTimer;
|
||||
|
||||
namespace MAME.Core
|
||||
{
|
||||
@ -617,14 +619,20 @@ namespace MAME.Core
|
||||
//}
|
||||
|
||||
//手动内联
|
||||
public unsafe void chan_calc(int c, int chnum)
|
||||
//public unsafe void chan_calc(int c, int chnum)
|
||||
public unsafe void chan_calc(int c, bool chnum_is_2)
|
||||
{
|
||||
uint eg_out;
|
||||
//减少寻址
|
||||
int imem_To_c = imem[c];//
|
||||
int imem_To_c = imem[c];
|
||||
fixed (FM_SLOT* CH_c_SLOT = &CH[c].SLOT[0])//因为是引用类型,所以敢这么玩
|
||||
fixed (int* out_fm_ptr = &out_fm[0])
|
||||
{
|
||||
FM_SLOT* cslot_0 = &CH_c_SLOT[0];
|
||||
FM_SLOT* cslot_1 = &CH_c_SLOT[1];
|
||||
FM_SLOT* cslot_2 = &CH_c_SLOT[2];
|
||||
FM_SLOT* cslot_3 = &CH_c_SLOT[3];
|
||||
|
||||
//out_fm[8] = out_fm[9] = out_fm[10] = out_fm[11] = 0; //本来就是注释->m2 = c1 = c2 = mem = 0;
|
||||
out_fm_ptr[8] = out_fm_ptr[9] = out_fm_ptr[10] = out_fm_ptr[11] = 0;
|
||||
|
||||
@ -633,7 +641,7 @@ namespace MAME.Core
|
||||
out_fm_ptr[imem_To_c] = CH[c].mem_value;
|
||||
|
||||
//eg_out = volume_calc(c, 0);
|
||||
eg_out = (uint)(CH_c_SLOT[0].vol_out + ((LFO_AM >> CH[c].ams) & CH_c_SLOT[0].AMmask));
|
||||
eg_out = (uint)(cslot_0->vol_out + ((LFO_AM >> CH[c].ams) & cslot_0->AMmask));
|
||||
|
||||
int out1 = CH[c].op1_out0 + CH[c].op1_out1;
|
||||
CH[c].op1_out0 = CH[c].op1_out1;
|
||||
@ -655,30 +663,56 @@ namespace MAME.Core
|
||||
{
|
||||
out1 = 0;
|
||||
}
|
||||
CH[c].op1_out1 = op_calc1(CH_c_SLOT[0].phase, eg_out, (out1 << CH[c].FB));
|
||||
|
||||
//CH[c].op1_out1 = op_calc1(cslot_0->phase, eg_out, (out1 << CH[c].FB)); //->(uint phase, uint env, int pm)
|
||||
uint p;
|
||||
p = (uint)((eg_out << 3) + sin_tab[(((int)((cslot_0->phase & 0xffff0000) + (out1 << CH[c].FB))) >> 16) & 0x3ff]);
|
||||
if (p >= 6656)
|
||||
CH[c].op1_out1 = 0;
|
||||
else
|
||||
CH[c].op1_out1 = tl_tab[p];
|
||||
}
|
||||
//eg_out = volume_calc(c, 1);
|
||||
eg_out = (uint)(CH_c_SLOT[1].vol_out + ((LFO_AM >> CH[c].ams) & CH_c_SLOT[1].AMmask));
|
||||
eg_out = (uint)(cslot_1->vol_out + ((LFO_AM >> CH[c].ams) & cslot_1->AMmask));
|
||||
if (eg_out < 832)
|
||||
{
|
||||
out_fm_ptr[iconnect3[c]] += op_calc(CH_c_SLOT[1].phase, eg_out, out_fm_ptr[8]);
|
||||
//out_fm_ptr[iconnect3[c]] += op_calc(cslot_1->phase, eg_out, out_fm_ptr[8]);//--> (uint phase, uint env, int pm)
|
||||
uint p;
|
||||
p = (uint)((eg_out << 3) + sin_tab[(((int)((cslot_1->phase & 0xffff0000) + (out_fm_ptr[8] << 15))) >> 16) & 0x3ff]);
|
||||
if (p >= 6656)
|
||||
out_fm_ptr[iconnect3[c]] += 0;
|
||||
else
|
||||
out_fm_ptr[iconnect3[c]] += tl_tab[p];
|
||||
}
|
||||
//eg_out = volume_calc(c, 2);
|
||||
eg_out = (uint)(CH_c_SLOT[2].vol_out + ((LFO_AM >> CH[c].ams) & CH_c_SLOT[2].AMmask));
|
||||
eg_out = (uint)(cslot_2->vol_out + ((LFO_AM >> CH[c].ams) & cslot_2->AMmask));
|
||||
if (eg_out < 832)
|
||||
{
|
||||
out_fm_ptr[iconnect2[c]] += op_calc(CH_c_SLOT[2].phase, eg_out, out_fm_ptr[9]);
|
||||
//out_fm_ptr[iconnect2[c]] += op_calc(cslot_2->phase, eg_out, out_fm_ptr[9]);//--> (uint phase, uint env, int pm)
|
||||
uint p;
|
||||
p = (uint)((eg_out << 3) + sin_tab[(((int)((cslot_2->phase & 0xffff0000) + (out_fm_ptr[9] << 15))) >> 16) & 0x3ff]);
|
||||
if (p >= 6656)
|
||||
out_fm_ptr[iconnect2[c]] += 0;
|
||||
else
|
||||
out_fm_ptr[iconnect2[c]] += tl_tab[p];
|
||||
}
|
||||
//eg_out = volume_calc(c, 3);
|
||||
eg_out = (uint)(CH_c_SLOT[3].vol_out + ((LFO_AM >> CH[c].ams) & CH_c_SLOT[3].AMmask));
|
||||
eg_out = (uint)(cslot_3->vol_out + ((LFO_AM >> CH[c].ams) & cslot_3->AMmask));
|
||||
if (eg_out < 832)
|
||||
{
|
||||
out_fm_ptr[iconnect4[c]] += op_calc(CH_c_SLOT[3].phase, eg_out, out_fm[10]);
|
||||
//out_fm_ptr[iconnect4[c]] += op_calc(cslot_3->phase, eg_out, out_fm[10]); //-->(uint phase, uint env, int pm)
|
||||
uint p;
|
||||
p = (uint)((eg_out << 3) + sin_tab[(((int)((cslot_3->phase & 0xffff0000) + (out_fm[10] << 15))) >> 16) & 0x3ff]);
|
||||
if (p >= 6656)
|
||||
out_fm_ptr[iconnect4[c]] += 0;
|
||||
else
|
||||
out_fm_ptr[iconnect4[c]] += tl_tab[p];
|
||||
}
|
||||
CH[c].mem_value = out_fm_ptr[11];//mem;
|
||||
if (CH[c].pms != 0)
|
||||
{
|
||||
if (((ST.mode & 0xC0) != 0) && (chnum == 2))
|
||||
//if (((ST.mode & 0xC0) != 0) && (chnum == 2))
|
||||
if (chnum_is_2 && ((ST.mode & 0xC0) != 0))
|
||||
{
|
||||
update_phase_lfo_slot(0, CH[c].pms, SL3.block_fnum[1]);
|
||||
update_phase_lfo_slot(2, CH[c].pms, SL3.block_fnum[2]);
|
||||
@ -692,10 +726,10 @@ namespace MAME.Core
|
||||
}
|
||||
else
|
||||
{
|
||||
CH_c_SLOT[0].phase += (uint)CH_c_SLOT[0].Incr;
|
||||
CH_c_SLOT[2].phase += (uint)CH_c_SLOT[2].Incr;
|
||||
CH_c_SLOT[1].phase += (uint)CH_c_SLOT[1].Incr;
|
||||
CH_c_SLOT[3].phase += (uint)CH_c_SLOT[3].Incr;
|
||||
cslot_0->phase += (uint)cslot_0->Incr;
|
||||
cslot_2->phase += (uint)cslot_2->Incr;
|
||||
cslot_1->phase += (uint)cslot_1->Incr;
|
||||
cslot_3->phase += (uint)cslot_3->Incr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -282,9 +282,12 @@ namespace MAME.Core
|
||||
OPN.advance_eg_channel(1);
|
||||
OPN.advance_eg_channel(2);
|
||||
}
|
||||
OPN.chan_calc(0, 0);
|
||||
OPN.chan_calc(1, 1);
|
||||
OPN.chan_calc(2, 2);
|
||||
//OPN.chan_calc(0, 0);
|
||||
//OPN.chan_calc(1, 1);
|
||||
//OPN.chan_calc(2, 2);
|
||||
OPN.chan_calc(0, false);
|
||||
OPN.chan_calc(1, false);
|
||||
OPN.chan_calc(2, true);
|
||||
{
|
||||
int lt;
|
||||
lt = FM.out_fm[0] + FM.out_fm[1] + FM.out_fm[2];
|
||||
|
||||
@ -509,10 +509,14 @@ namespace MAME.Core
|
||||
OPN.advance_eg_channel(4);
|
||||
OPN.advance_eg_channel(5);
|
||||
}
|
||||
OPN.chan_calc(1, 1);
|
||||
OPN.chan_calc(2, 2);
|
||||
OPN.chan_calc(4, 4);
|
||||
OPN.chan_calc(5, 5);
|
||||
//OPN.chan_calc(1, 1);
|
||||
//OPN.chan_calc(2, 2);
|
||||
//OPN.chan_calc(4, 4);
|
||||
//OPN.chan_calc(5, 5);
|
||||
OPN.chan_calc(1, false);
|
||||
OPN.chan_calc(2, true);
|
||||
OPN.chan_calc(4, false);
|
||||
OPN.chan_calc(5, false);
|
||||
if ((YMDeltat.DELTAT.portstate & 0x80) != 0)
|
||||
{
|
||||
YMDeltat.YM_DELTAT_ADPCM_CALC();
|
||||
@ -588,12 +592,18 @@ namespace MAME.Core
|
||||
OPN.advance_eg_channel(4);
|
||||
OPN.advance_eg_channel(5);
|
||||
}
|
||||
OPN.chan_calc(0, 0);
|
||||
OPN.chan_calc(1, 1);
|
||||
OPN.chan_calc(2, 2);
|
||||
OPN.chan_calc(3, 3);
|
||||
OPN.chan_calc(4, 4);
|
||||
OPN.chan_calc(5, 5);
|
||||
//OPN.chan_calc(0, 0);
|
||||
//OPN.chan_calc(1, 1);
|
||||
//OPN.chan_calc(2, 2);
|
||||
//OPN.chan_calc(3, 3);
|
||||
//OPN.chan_calc(4, 4);
|
||||
//OPN.chan_calc(5, 5);
|
||||
OPN.chan_calc(0, false);
|
||||
OPN.chan_calc(1, false);
|
||||
OPN.chan_calc(2, true);
|
||||
OPN.chan_calc(3, false);
|
||||
OPN.chan_calc(4, false);
|
||||
OPN.chan_calc(5, false);
|
||||
if ((YMDeltat.DELTAT.portstate & 0x80) != 0)
|
||||
{
|
||||
YMDeltat.YM_DELTAT_ADPCM_CALC();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user