From 909d1b35f15a6cdc7edf7055bfc457d4528b843f Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Wed, 12 Nov 2025 00:09:34 +0800 Subject: [PATCH] =?UTF-8?q?MAME:=E5=86=85=E8=81=94=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E5=92=8C=E9=9F=B3=E9=A2=91=E5=87=BD=E6=95=B0=EF=BC=8C=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E4=B8=80=E4=BA=9B=E6=95=B0=E7=BB=84=E9=AB=98=E9=A2=91?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E5=9B=BA=E5=AE=9Aindex=EF=BC=8C=E5=87=8F?= =?UTF-8?q?=E5=B0=91=E5=AF=BB=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Plugins/Mame.Core/emu/Motion.cs | 3 +- .../Plugins/Mame.Core/mame/neogeo/Video.cs | 36 +++++- .../Assets/Plugins/Mame.Core/sound/FM.cs | 114 +++++++++++++++--- 3 files changed, 133 insertions(+), 20 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Motion.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Motion.cs index a363ee62..b932dfb7 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Motion.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Motion.cs @@ -325,7 +325,8 @@ red = ((Video.bitmapbaseN_Ptrs[Video.curbitmap][i] & 0xff0000) >> 16) * bright / 0xff; green = ((Video.bitmapbaseN_Ptrs[Video.curbitmap][i] & 0xff00) >> 8) * bright / 0xff; blue = (Video.bitmapbaseN_Ptrs[Video.curbitmap][i] & 0xff) * bright / 0xff; - Video.bitmapcolorRect_Ptrunsafe[target_i] = (int)Palette.make_argb(0xff, red, green, blue); + //Video.bitmapcolorRect_Ptrunsafe[target_i] = (int)Palette.make_argb(0xff, red, green, blue); + Video.bitmapcolorRect_Ptrunsafe[target_i] = (int)((((uint)(0xff) & 0xff) << 24) | (((uint)(blue) & 0xff) << 16) | (((uint)(green) & 0xff) << 8) | ((uint)(red) & 0xff)); } } } diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/neogeo/Video.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/neogeo/Video.cs index 15e53f53..fa07ebf3 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/neogeo/Video.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/neogeo/Video.cs @@ -143,9 +143,20 @@ namespace MAME.Core rows = 0x20; return rows * 0x10; } + //public static bool sprite_on_scanline(int scanline, int y, int rows) + //{ + // int max_y = (y + rows_to_height(rows) - 1) & 0x1ff; + // return (((max_y >= y) && (scanline >= y) && (scanline <= max_y)) || + // ((max_y < y) && ((scanline >= y) || (scanline <= max_y)))); + //} + + //手动内联 public static bool sprite_on_scanline(int scanline, int y, int rows) { - int max_y = (y + rows_to_height(rows) - 1) & 0x1ff; + //int max_y = (y + rows_to_height(rows) - 1) & 0x1ff; + if ((rows == 0) || (rows > 0x20)) + rows = 0x20; + int max_y = (y + (rows * 0x10) - 1) & 0x1ff; return (((max_y >= y) && (scanline >= y) && (scanline <= max_y)) || ((max_y < y) && ((scanline >= y) || (scanline <= max_y)))); } @@ -405,7 +416,16 @@ namespace MAME.Core { continue; } - if (sprite_on_scanline(scanline, y, rows)) + + //if (sprite_on_scanline(scanline, y, rows)) + //手动内联 开始 + int tempRows = rows; + if ((rows == 0) || (rows > 0x20)) + tempRows = 0x20; + int max_y = (y + (tempRows * 0x10) - 1) & 0x1ff; + if (((max_y >= y) && (scanline >= y) && (scanline <= max_y)) || + ((max_y < y) && ((scanline >= y) || (scanline <= max_y)))) + //手动内联 结束 { sprite_line = (scanline - y) & 0x1ff; zoom_line = sprite_line & 0xff; @@ -704,7 +724,17 @@ namespace MAME.Core { continue; } - if (!sprite_on_scanline(scanline, y, rows)) + + //if (!sprite_on_scanline(scanline, y, rows)) + + //手动内联 开始 + int tempRows = rows; + if ((rows == 0) || (rows > 0x20)) + tempRows = 0x20; + int max_y = (y + (tempRows * 0x10) - 1) & 0x1ff; + if (!(((max_y >= y) && (scanline >= y) && (scanline <= max_y)) || + ((max_y < y) && ((scanline >= y) || (scanline <= max_y))))) + //手动内联 结束 { continue; } diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/FM.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/FM.cs index e9c81e9b..a46a37a6 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/FM.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/FM.cs @@ -482,8 +482,9 @@ namespace MAME.Core } private uint volume_calc(int c, int s) { - int AM = LFO_AM >> CH[c].ams; - return (uint)(CH[c].SLOT[s].vol_out + (AM & CH[c].SLOT[s].AMmask)); + //int AM = LFO_AM >> CH[c].ams; + //return (uint)(CH[c].SLOT[s].vol_out + (AM & CH[c].SLOT[s].AMmask)); + return (uint)(CH[c].SLOT[s].vol_out + ((LFO_AM >> CH[c].ams) & CH[c].SLOT[s].AMmask)); } private void update_phase_lfo_slot(int s, int pms, uint block_fnum) { @@ -558,15 +559,93 @@ namespace MAME.Core CH[c].SLOT[3].phase += (uint)CH[c].SLOT[3].Incr; } } + //public void chan_calc(int c, int chnum) + //{ + // uint eg_out; + // out_fm[8] = out_fm[9] = out_fm[10] = out_fm[11] = 0;//m2 = c1 = c2 = mem = 0; + // set_mem(c); + // eg_out = volume_calc(c, 0); + // int out1 = CH[c].op1_out0 + CH[c].op1_out1; + // CH[c].op1_out0 = CH[c].op1_out1; + // set_value1(c); + // CH[c].op1_out1 = 0; + // if (eg_out < 832) + // { + // if (CH[c].FB == 0) + // { + // out1 = 0; + // } + // CH[c].op1_out1 = op_calc1(CH[c].SLOT[0].phase, eg_out, (out1 << CH[c].FB)); + // } + // eg_out = volume_calc(c, 1); + // if (eg_out < 832) + // { + // out_fm[iconnect3[c]] += op_calc(CH[c].SLOT[1].phase, eg_out, out_fm[8]); + // } + // eg_out = volume_calc(c, 2); + // if (eg_out < 832) + // { + // out_fm[iconnect2[c]] += op_calc(CH[c].SLOT[2].phase, eg_out, out_fm[9]); + // } + // eg_out = volume_calc(c, 3); + // if (eg_out < 832) + // { + // out_fm[iconnect4[c]] += op_calc(CH[c].SLOT[3].phase, eg_out, out_fm[10]); + // } + // CH[c].mem_value = out_fm[11];//mem; + // if (CH[c].pms != 0) + // { + // if (((ST.mode & 0xC0) != 0) && (chnum == 2)) + // { + // update_phase_lfo_slot(0, CH[c].pms, SL3.block_fnum[1]); + // update_phase_lfo_slot(2, CH[c].pms, SL3.block_fnum[2]); + // update_phase_lfo_slot(1, CH[c].pms, SL3.block_fnum[0]); + // update_phase_lfo_slot(3, CH[c].pms, CH[c].block_fnum); + // } + // else + // { + // update_phase_lfo_channel(CH, c); + // } + // } + // 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; + // } + //} + + //手动内联 public void chan_calc(int c, int chnum) { uint eg_out; out_fm[8] = out_fm[9] = out_fm[10] = out_fm[11] = 0;//m2 = c1 = c2 = mem = 0; - set_mem(c); - eg_out = volume_calc(c, 0); + + //减少寻址 + int imem_To_c = imem[c];// + FM_SLOT[] CH_c_SLOT = CH[c].SLOT;//因为是引用类型,所以敢这么玩 + + //set_mem(c); + if (imem_To_c == 8 || imem_To_c == 10 || imem_To_c == 11) + out_fm[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)); + int out1 = CH[c].op1_out0 + CH[c].op1_out1; CH[c].op1_out0 = CH[c].op1_out1; - set_value1(c); + + //set_value1(c); + if (iconnect1[c] == 12) + { + out_fm[11] = out_fm[9] = out_fm[10] = CH[c].op1_out0; + } + else + { + out_fm[iconnect1[c]] = CH[c].op1_out0; + } + CH[c].op1_out1 = 0; if (eg_out < 832) { @@ -574,22 +653,25 @@ 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(CH_c_SLOT[0].phase, eg_out, (out1 << CH[c].FB)); } - eg_out = volume_calc(c, 1); + //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)); if (eg_out < 832) { - out_fm[iconnect3[c]] += op_calc(CH[c].SLOT[1].phase, eg_out, out_fm[8]); + out_fm[iconnect3[c]] += op_calc(CH_c_SLOT[1].phase, eg_out, out_fm[8]); } - eg_out = volume_calc(c, 2); + //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)); if (eg_out < 832) { - out_fm[iconnect2[c]] += op_calc(CH[c].SLOT[2].phase, eg_out, out_fm[9]); + out_fm[iconnect2[c]] += op_calc(CH_c_SLOT[2].phase, eg_out, out_fm[9]); } - eg_out = volume_calc(c, 3); + //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)); if (eg_out < 832) { - out_fm[iconnect4[c]] += op_calc(CH[c].SLOT[3].phase, eg_out, out_fm[10]); + out_fm[iconnect4[c]] += op_calc(CH_c_SLOT[3].phase, eg_out, out_fm[10]); } CH[c].mem_value = out_fm[11];//mem; if (CH[c].pms != 0) @@ -608,10 +690,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; + 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; } } public void refresh_fc_eg_slot(int type, int c, int s, int fc, int kc)