diff --git a/CHANGE.txt b/CHANGE.txt index 93ebaac..6769ab8 100644 --- a/CHANGE.txt +++ b/CHANGE.txt @@ -1,4 +1,9 @@ 更新履歴 +STBL483 2024/11/10 2nd + PianoRoll:発声が続いているにもかかわらず、表示が途中で途切れることがあるのを修正 + PianoRoll:Chip:YM2413追加 + XGM2:再生できなくなっていたバグをとりあえず修正 + STBL482 2024/11/10 PianoRoll:Driver:HES追加 PianoRoll:Chip:HuC6280追加 diff --git a/MDPlayer/MDPlayer-STBL481.exe b/MDPlayer/MDPlayer-STBL482.exe similarity index 72% rename from MDPlayer/MDPlayer-STBL481.exe rename to MDPlayer/MDPlayer-STBL482.exe index d0938bc..e758d7e 100644 Binary files a/MDPlayer/MDPlayer-STBL481.exe and b/MDPlayer/MDPlayer-STBL482.exe differ diff --git a/MDPlayer/MDPlayer_InstKit/02info.nsh b/MDPlayer/MDPlayer_InstKit/02info.nsh index 1080dc6..5f916f8 100644 --- a/MDPlayer/MDPlayer_InstKit/02info.nsh +++ b/MDPlayer/MDPlayer_InstKit/02info.nsh @@ -1,4 +1,4 @@ !define NAME "MDPlayer" -!define VERSION "STBL481" +!define VERSION "STBL482" !define PUBLISHER "Kumata" !define PACKAGE "${NAME} ${VERSION}" diff --git a/MDPlayer/MDPlayerx64/Audio.cs b/MDPlayer/MDPlayerx64/Audio.cs index d728593..e7b8337 100644 --- a/MDPlayer/MDPlayerx64/Audio.cs +++ b/MDPlayer/MDPlayerx64/Audio.cs @@ -3123,7 +3123,7 @@ public static bool MgsPlay_mgsdrv(Setting setting) if (useOPLL) { - chipRegister.setYM2413Register(0, 14, 32, EnmModel.VirtualModel); + chipRegister.setYM2413Register(0, 14, 32, EnmModel.VirtualModel,0); //chipRegister.setYM2610Register(0, 0, 0x11, 0xc0, EnmModel.VirtualModel); } @@ -3296,7 +3296,7 @@ public static bool MscPlay_mscdrv(Setting setting) if (useOPLL) { - chipRegister.setYM2413Register(0, 14, 32, EnmModel.VirtualModel); + chipRegister.setYM2413Register(0, 14, 32, EnmModel.VirtualModel, 0); } if (!DriverVirtual.init(vgmBuf, chipRegister, EnmModel.VirtualModel, new EnmChip[] { EnmChip.AY8910, EnmChip.YM2413, EnmChip.K051649 } diff --git a/MDPlayer/MDPlayerx64/ChipRegister.cs b/MDPlayer/MDPlayerx64/ChipRegister.cs index 64d9cce..2ad7547 100644 --- a/MDPlayer/MDPlayerx64/ChipRegister.cs +++ b/MDPlayer/MDPlayerx64/ChipRegister.cs @@ -2059,9 +2059,13 @@ public void setGA20Register(int chipID, Int32 Adr, byte Dat, EnmModel model) } } - public void setYM2413Register(int chipID, int dAddr, int dData, EnmModel model) + public void setYM2413Register(int chipID, int dAddr, int dData, EnmModel model,long vgmFrameCounter) { - if (model == EnmModel.PianoRollModel) return; + if (model == EnmModel.PianoRollModel) + { + pianoRollMng.SetRegister(EnmChip.YM2413, chipID, dAddr, dData, vgmFrameCounter); + return; + } if (ctYM2413 == null) return; @@ -2541,18 +2545,18 @@ public void softResetYM2413(int chipID, EnmModel model) // FM蜈ィ繝√Ε繝阪Ν繧ュ繝シ繧ェ繝 for (int ch = 0; ch < 9; ch++) { - setYM2413Register(chipID, 0x20 + ch, 0x00, model); + setYM2413Register(chipID, 0x20 + ch, 0x00, model, 0); } - setYM2413Register(chipID, 0x0e, 0x00, model); + setYM2413Register(chipID, 0x0e, 0x00, model, 0); // FM TL=15 for (int ch = 0; ch < 9; ch++) { - setYM2413Register(chipID, 0x30 + ch, 0x0f, model); + setYM2413Register(chipID, 0x30 + ch, 0x0f, model, 0); } - setYM2413Register(chipID, 0x36, 0x0f, model); - setYM2413Register(chipID, 0x37, 0xff, model); - setYM2413Register(chipID, 0x38, 0xff, model); + setYM2413Register(chipID, 0x36, 0x0f, model, 0); + setYM2413Register(chipID, 0x37, 0xff, model, 0); + setYM2413Register(chipID, 0x38, 0xff, model, 0); } @@ -4827,13 +4831,13 @@ public void setMaskYM2413(int chipID, int ch, bool mask) if (ch < 9) { - setYM2413Register((byte)chipID, 0x20 + ch, fmRegisterYM2413[chipID][0x20 + ch], EnmModel.VirtualModel); - setYM2413Register((byte)chipID, 0x20 + ch, fmRegisterYM2413[chipID][0x20 + ch], EnmModel.RealModel); + setYM2413Register((byte)chipID, 0x20 + ch, fmRegisterYM2413[chipID][0x20 + ch], EnmModel.VirtualModel, 0); + setYM2413Register((byte)chipID, 0x20 + ch, fmRegisterYM2413[chipID][0x20 + ch], EnmModel.RealModel, 0); } else if (ch < 14) { - setYM2413Register((byte)chipID, 0x0e, fmRegisterYM2413[chipID][0x0e], EnmModel.VirtualModel); - setYM2413Register((byte)chipID, 0x0e, fmRegisterYM2413[chipID][0x0e], EnmModel.RealModel); + setYM2413Register((byte)chipID, 0x0e, fmRegisterYM2413[chipID][0x0e], EnmModel.VirtualModel, 0); + setYM2413Register((byte)chipID, 0x0e, fmRegisterYM2413[chipID][0x0e], EnmModel.RealModel, 0); } } @@ -5290,7 +5294,7 @@ public void setFadeoutVolYM2413(int chipID, int v) nowYM2413FadeoutVol[chipID] = v / (128 / 16); for (int c = 0; c < 9; c++) { - setYM2413Register(chipID, 0x30 + c, fmRegisterYM2413[chipID][0x30 + c], EnmModel.RealModel); + setYM2413Register(chipID, 0x30 + c, fmRegisterYM2413[chipID][0x30 + c], EnmModel.RealModel, 0); } } diff --git a/MDPlayer/MDPlayerx64/Driver/MGSDRV/MsxPort.cs b/MDPlayer/MDPlayerx64/Driver/MGSDRV/MsxPort.cs index d2b2408..b89ccab 100644 --- a/MDPlayer/MDPlayerx64/Driver/MGSDRV/MsxPort.cs +++ b/MDPlayer/MDPlayerx64/Driver/MGSDRV/MsxPort.cs @@ -70,7 +70,7 @@ private void OutPort(int address, byte value) opllAdr = value; break; case 0x7d: - chipRegister?.setYM2413Register(0, opllAdr, value, model); + chipRegister?.setYM2413Register(0, opllAdr, value, model, driver.vgmFrameCounter); //log.Write("OPLL Port Adr:{0:x04} Dat:{1:x02}", address, value); break; case 0xa8: diff --git a/MDPlayer/MDPlayerx64/Driver/S98/S98.cs b/MDPlayer/MDPlayerx64/Driver/S98/S98.cs index 768ed34..a3f77ea 100644 --- a/MDPlayer/MDPlayerx64/Driver/S98/S98.cs +++ b/MDPlayer/MDPlayerx64/Driver/S98/S98.cs @@ -584,7 +584,7 @@ private void WriteYM2151(int chipID, byte port, byte adr, byte data) private void WriteYM2413(int chipID, byte adr, byte data) { - chipRegister.setYM2413Register(chipID, adr, data, model); + chipRegister.setYM2413Register(chipID, adr, data, model,vgmFrameCounter); } private void WriteYM3526(int chipID, byte adr, byte data) diff --git a/MDPlayer/MDPlayerx64/Driver/vgm.cs b/MDPlayer/MDPlayerx64/Driver/vgm.cs index 3dcb23b..d69a657 100644 --- a/MDPlayer/MDPlayerx64/Driver/vgm.cs +++ b/MDPlayer/MDPlayerx64/Driver/vgm.cs @@ -639,7 +639,7 @@ private void VcX1_010() private void VcYM2413() { - chipRegister.setYM2413Register((vgmBuf[vgmAdr] & 0x80) == 0 ? 0 : 1, vgmBuf[vgmAdr + 1], vgmBuf[vgmAdr + 2], model); + chipRegister.setYM2413Register((vgmBuf[vgmAdr] & 0x80) == 0 ? 0 : 1, vgmBuf[vgmAdr + 1], vgmBuf[vgmAdr + 2], model, vgmFrameCounter); vgmAdr += 3; } diff --git a/MDPlayer/MDPlayerx64/Driver/xgm2.cs b/MDPlayer/MDPlayerx64/Driver/xgm2.cs index b598d9a..9ad9eeb 100644 --- a/MDPlayer/MDPlayerx64/Driver/xgm2.cs +++ b/MDPlayer/MDPlayerx64/Driver/xgm2.cs @@ -393,7 +393,7 @@ private void oneFrameXGM() private void oneFrameFM() { if (fmWaitCnt-- > 0) return; - + if (vgmBuf == null) return; while (true) { if (fmmusicPtr >= vgmBuf.Length) { endFm = true; return; } @@ -688,6 +688,7 @@ private void SendInst(byte cs, byte port, byte[] vd) private void oneFramePsg() { if (psgWaitCnt-- > 0) return; + if (vgmBuf == null) return; while (true) { if (psgmusicPtr >= vgmBuf.Length) { endPsg = true; return; } @@ -867,7 +868,7 @@ private void WriteYM2612P0(byte adr, byte val) if (adr == 0x2b) DACEnable = (byte)(val & 0x80); else if (adr == 0x27) ch3spEnable = ((val & 0x40) != 0); - chipRegister.setYM2612Register(0, 0, adr, val, model, vgmFrameCounter); + chipRegister?.setYM2612Register(0, 0, adr, val, model, vgmFrameCounter); } private void WriteYM2612P1(byte adr, byte val) diff --git a/MDPlayer/MDPlayerx64/PianoRoll/YM2413.cs b/MDPlayer/MDPlayerx64/PianoRoll/YM2413.cs new file mode 100644 index 0000000..67ac374 --- /dev/null +++ b/MDPlayer/MDPlayerx64/PianoRoll/YM2413.cs @@ -0,0 +1,102 @@ +サソusing MDPlayer; +using NAudio.Gui; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MDPlayerx64.PianoRoll +{ + public class YM2413(List lstPrNote, int MAXChip = 2) : BaseChip(lstPrNote, MAXChip) + { + private List reg; + private List KeyOn; + private List KeyOnOld; + private List Fnum; + private List FnumOld; + private List Note; + + public override void Clear() + { + reg = []; + KeyOn = []; + KeyOnOld = []; + Fnum = []; + FnumOld = []; + Note = []; + for (int i = 0; i < MAXChip; i++) + { + reg.Add(new byte[0x100]); + KeyOn.Add([false, false, false, false, false, false, false, false, false]); + KeyOnOld.Add([false, false, false, false, false, false, false, false, false]); + Fnum.Add([-1, -1, -1, -1, -1, -1, -1, -1, -1]); + FnumOld.Add([-1, -1, -1, -1, -1, -1, -1, -1, -1]); + Note.Add(new PrNote[9]); + } + } + + public override void Analyze(int chipID, int dAdr, int dData, long vgmFrameCounter) + { + reg[chipID][dAdr] = (byte)dData; + if (dAdr < 0x10 || (dAdr >= 0x19 && dAdr < 0x20) || dAdr >= 0x29) return; + + int ch = dAdr & 0xf; + int freq = reg[chipID][0x10 + ch] + ((reg[chipID][0x20 + ch] & 0x1) << 8); + int oct = ((reg[chipID][0x20 + ch] & 0xe) >> 1); + int fnum = Common.searchSegaPCMNote(freq / 172.0) + (oct - 4) * 12; + int k = reg[chipID][0x20 + ch] & 0x10; + KeyOn[chipID][ch] = k != 0; + Fnum[chipID][ch] = fnum; + + if (KeyOnOld[chipID][ch] == KeyOn[chipID][ch] + && FnumOld[chipID][ch] == Fnum[chipID][ch] + ) return; + KeyOnOld[chipID][ch] = KeyOn[chipID][ch]; + FnumOld[chipID][ch] = Fnum[chipID][ch]; + + if (!KeyOn[chipID][ch]) + { + //keyOff + if (Note[chipID][ch] != null) + Note[chipID][ch].endTick = vgmFrameCounter; + return; + } + + //keyOn + if (Note[chipID][ch] != null && Note[chipID][ch].endTick == -1) + Note[chipID][ch].endTick = vgmFrameCounter; + + Note[chipID][ch] = MakeNote(ch, vgmFrameCounter, fnum, freq); + lstPrNote.Add(Note[chipID][ch]); + + } + + private static PrNote MakeNote(int ch, long startTick, int ff, int freq) + { + PrNote ret = new PrNote + { + ch = ch, + startTick = startTick, + endTick = -1,//髟キ縺墓悴遒コ螳 + key = 95 - ff, + freq = freq + }; + ret.noteColor1[0] = 0xd0; + ret.noteColor1[1] = 0x00; + ret.noteColor1[2] = 0x50; + ret.noteColor1[3] = 0xf0; + ret.noteColor1[4] = 0x00; + ret.noteColor1[5] = 0x70; + ret.noteColor2[0] = 0x90; + ret.noteColor2[1] = 0x00; + ret.noteColor2[2] = 0x90; + ret.noteColor2[3] = 0xd0; + ret.noteColor2[4] = 0x00; + ret.noteColor2[5] = 0xb0; + + return ret; + } + + } +} diff --git a/MDPlayer/MDPlayerx64/PianoRollMng.cs b/MDPlayer/MDPlayerx64/PianoRollMng.cs index f1ab06f..e6bea94 100644 --- a/MDPlayer/MDPlayerx64/PianoRollMng.cs +++ b/MDPlayer/MDPlayerx64/PianoRollMng.cs @@ -21,6 +21,7 @@ public PianoRollMng() chipList.Add(EnmChip.AY8910, new MDPlayerx64.PianoRoll.AY8910(lstPrNote)); chipList.Add(EnmChip.HuC6280, new MDPlayerx64.PianoRoll.HuC6280(lstPrNote)); chipList.Add(EnmChip.YM2151, new MDPlayerx64.PianoRoll.YM2151(lstPrNote)); + chipList.Add(EnmChip.YM2413, new MDPlayerx64.PianoRoll.YM2413(lstPrNote)); chipList.Add(EnmChip.YM2608, new MDPlayerx64.PianoRoll.YM2608(lstPrNote)); chipList.Add(EnmChip.YM2610, new MDPlayerx64.PianoRoll.YM2610(lstPrNote)); chipList.Add(EnmChip.YM2612, new MDPlayerx64.PianoRoll.YM2612(lstPrNote)); diff --git a/MDPlayer/MDPlayerx64/dacControl.cs b/MDPlayer/MDPlayerx64/dacControl.cs index be65349..59c320b 100644 --- a/MDPlayer/MDPlayerx64/dacControl.cs +++ b/MDPlayer/MDPlayerx64/dacControl.cs @@ -472,7 +472,7 @@ private void chip_reg_write(byte ChipType2, byte ChipID, byte Port, byte Offset, chipRegister.setSN76489Register(ChipID, Data, model, 0); break; case 0x01: // YM2413+ - chipRegister.setYM2413Register(ChipID, Offset, Data, model); + chipRegister.setYM2413Register(ChipID, Offset, Data, model, 0); break; case 0x02: // YM2612 chipRegister.setYM2612Register(ChipID, Port, Offset, Data, model, -1); diff --git a/MDPlayer/MDPlayerx64/form/SYS/frmPianoRoll.cs b/MDPlayer/MDPlayerx64/form/SYS/frmPianoRoll.cs index aba27f9..a5920ae 100644 --- a/MDPlayer/MDPlayerx64/form/SYS/frmPianoRoll.cs +++ b/MDPlayer/MDPlayerx64/form/SYS/frmPianoRoll.cs @@ -120,6 +120,10 @@ public void screenDrawParams() i--; continue; } + if (n.endTick == -1 && x < 0) + { + x = 0; + } for (int j = 0; j < 6; j++) {