MAME:解决NEOGEO加载BIOS时开销大的问题,核心是mame watchdog在加载bios时每帧进行数千次watchdog reset,其实每帧至多只需要一次即可得到等效效果,进行一个限制,加载BIOS时和平常游戏时性能接近

This commit is contained in:
sin365 2025-11-12 16:13:37 +08:00
parent e07dfa6b3e
commit d7322d8e91
2 changed files with 76 additions and 4 deletions

View File

@ -42,8 +42,22 @@
{
Mame.mame_schedule_soft_reset();
}
static long LastCheckFrame;
static int frame_reset_count;
const byte maxLimitReset_everyFrame = 1;
public static void watchdog_reset()
{
if (LastCheckFrame != Video.screenstate.frame_number)
{
LastCheckFrame = Video.screenstate.frame_number;
//UnityEngine.Debug.Log($"上一帧数跳过watchdog_reset:{frame_reset_count}次");
frame_reset_count = 0;
}
frame_reset_count++;
if (frame_reset_count > maxLimitReset_everyFrame)
return;
if (!watchdog_enabled)
{
EmuTimer.timer_adjust_periodic(watchdog_timer, Attotime.ATTOTIME_NEVER, Attotime.ATTOTIME_NEVER);
@ -57,5 +71,20 @@
EmuTimer.timer_adjust_periodic(watchdog_timer, new Atime(3, 0), Attotime.ATTOTIME_NEVER);
}
}
//public static void watchdog_reset()
//{
// if (!watchdog_enabled)
// {
// EmuTimer.timer_adjust_periodic(watchdog_timer, Attotime.ATTOTIME_NEVER, Attotime.ATTOTIME_NEVER);
// }
// else if (Attotime.attotime_compare(watchdog_time, Attotime.ATTOTIME_ZERO) != 0)
// {
// EmuTimer.timer_adjust_periodic(watchdog_timer, watchdog_time, Attotime.ATTOTIME_NEVER);
// }
// else
// {
// EmuTimer.timer_adjust_periodic(watchdog_timer, new Atime(3, 0), Attotime.ATTOTIME_NEVER);
// }
//}
}
}

View File

@ -175,6 +175,49 @@ namespace MAME.Core
}
return result;
}
//public static short MReadOpWord(int address)
//{
// address &= 0xffffff;
// short result = 0;
// if (address >= 0x000000 && address + 1 <= 0x00007f)
// {
// if (main_cpu_vector_table_source == 0)
// {
// result = (short)(mainbiosrom[address] * 0x100 + mainbiosrom[address + 1]);
// }
// else if (main_cpu_vector_table_source == 1)
// {
// result = (short)(Memory.mainrom[address] * 0x100 + Memory.mainrom[address + 1]);
// }
// }
// else if (address >= 0x000080 && address + 1 <= 0x0fffff)
// {
// if (address >= 0x142B9 && address <= 0x142C9)
// {
// //m68000Form.iStatus = 1;
// }
// result = (short)(Memory.mainrom[address] * 0x100 + Memory.mainrom[address + 1]);
// }
// else if (address >= 0x100000 && address + 1 <= 0x1fffff)
// {
// result = (short)(Memory.mainram[address & 0xffff] * 0x100 + Memory.mainram[(address & 0xffff) + 1]);
// }
// else if (address >= 0x200000 && address + 1 <= 0x2fffff)
// {
// result = (short)(Memory.mainrom[main_cpu_bank_address + (address & 0xfffff)] * 0x100 + Memory.mainrom[main_cpu_bank_address + (address & 0xfffff) + 1]);
// }
// else if (address >= 0xc00000 && address + 1 <= 0xcfffff)
// {
// result = (short)(mainbiosrom[address & 0x1ffff] * 0x100 + mainbiosrom[(address & 0x1ffff) + 1]);
// }
// else
// {
// result = 0;
// }
// return result;
//}
//手动优化
public static short MReadOpWord(int address)
{
address &= 0xffffff;
@ -192,10 +235,10 @@ namespace MAME.Core
}
else if (address >= 0x000080 && address + 1 <= 0x0fffff)
{
if (address >= 0x142B9 && address <= 0x142C9)
{
//m68000Form.iStatus = 1;
}
//if (address >= 0x142B9 && address <= 0x142C9)
//{
// //m68000Form.iStatus = 1;
//}
result = (short)(Memory.mainrom[address] * 0x100 + Memory.mainrom[address + 1]);
}
else if (address >= 0x100000 && address + 1 <= 0x1fffff)