Skip to content

Commit

Permalink
STBL478 2024/11/08
Browse files Browse the repository at this point in the history
  PianoRoll:Driver:MGSDRV,MuSICA追加
  PianoRoll:Chip:AY8910追加
  • Loading branch information
kumatan committed Nov 8, 2024
1 parent 7e30921 commit 657850a
Show file tree
Hide file tree
Showing 21 changed files with 244 additions and 52 deletions.
4 changes: 4 additions & 0 deletions CHANGE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
�X�V����
STBL478 2024/11/08
PianoRoll:Driver:MGSDRV,MuSICA�lj�
PianoRoll:Chip:AY8910�lj�

STBL477 2024/11/04 3rd
PianoRoll:OPM�lj�

Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion MDPlayer/MDPlayer_InstKit/02info.nsh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!define NAME "MDPlayer"
!define VERSION "STBL476"
!define VERSION "STBL477"
!define PUBLISHER "Kumata"
!define PACKAGE "${NAME} ${VERSION}"
23 changes: 23 additions & 0 deletions MDPlayer/MDPlayer_InstKit/_inst_mui2.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,22 @@ Function test
${If} $0 != ""
StrCpy $INSTDIR "$0"
${EndIf}

!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"
!define MUI_FINISHPAGE_RUN_CHECKED
# ReadRegStr $0 HKLM ${RegistryKey} "RunAfterInstalled"
# ${If} $0 == ""
# !define MUI_FINISHPAGE_RUN_CHECKED
# ${Else}
# !define MUI_FINISHPAGE_RUN_UNCHECKED
# ${EndIf}

FunctionEnd

!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_WELCOME
Expand Down Expand Up @@ -68,6 +80,9 @@ Section "Install" SECTION_INSTALL

# アンインストール情報をレジストリに登録
WriteRegStr HKLM ${RegistryKey} "InstallDir" "$INSTDIR"
# インストール完了時のプログラム起動確認チェックボックスの
# (ユーザーが選択した)状態を取得する方法が分からず未実装
# WriteRegStr HKLM ${RegistryKey} "RunAfterInstalled" "$RUN"
WriteRegStr HKLM ${RegistryKey} "DisplayName" "${NAME}"
WriteRegStr HKLM ${RegistryKey} "UninstallString" '"$INSTDIR\Uninstall.exe"'
WriteRegStr HKLM ${RegistryKey} "Publisher" '"${PUBLISHER}"'
Expand All @@ -93,6 +108,14 @@ Section "Uninstall"
DeleteRegKey HKLM ${RegistryKey}
SectionEnd

Function LaunchLink
#MessageBox MB_OK "Reached LaunchLink $\r$\n \
# SMPROGRAMS: $SMPROGRAMS $\r$\n \
# Start Menu Folder: $STARTMENU_FOLDER $\r$\n \
# InstallDirectory: $INSTDIR "
ExecShell "" "$INSTDIR\MDPlayerx64.exe"
FunctionEnd

# 署名する
!finalize 'SignExe.bat "%1"'
!uninstfinalize 'SignExe.bat "%1"'
39 changes: 39 additions & 0 deletions MDPlayer/MDPlayerx64/Audio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2078,6 +2078,15 @@ public static bool Play(Setting setting)
};
((Driver.MGSDRV.MGSDRV)DriverReal).PlayingFileName = PlayingFileName;
}
DriverPianoRoll = null;
if (setting.pianoRoll.usePianoRoll)
{
DriverPianoRoll = new Driver.MGSDRV.MGSDRV
{
setting = setting
};
((Driver.MGSDRV.MGSDRV)DriverPianoRoll).PlayingFileName = PlayingFileName;
}
return MgsPlay_mgsdrv(setting);
}

Expand All @@ -2097,6 +2106,15 @@ public static bool Play(Setting setting)
};
((Driver.MuSICA.MuSICA)DriverReal).PlayingFileName = PlayingFileName;
}
DriverPianoRoll = null;
if (setting.pianoRoll.usePianoRoll)
{
DriverPianoRoll = new Driver.MuSICA.MuSICA
{
setting = setting
};
((Driver.MuSICA.MuSICA)DriverPianoRoll).PlayingFileName = PlayingFileName;
}
return MscPlay_mscdrv(setting);
}

Expand Down Expand Up @@ -2128,6 +2146,15 @@ public static bool Play(Setting setting)
};
((Driver.MuSICA.MuSICA)DriverReal).PlayingFileName = PlayingFileName;
}
DriverPianoRoll = null;
if (setting.pianoRoll.usePianoRoll)
{
DriverPianoRoll = new Driver.MuSICA.MuSICA
{
setting = setting
};
((Driver.MuSICA.MuSICA)DriverPianoRoll).PlayingFileName = PlayingFileName;
}
return MscPlay_mscdrv(setting);
}

Expand Down Expand Up @@ -3022,6 +3049,12 @@ public static bool MgsPlay_mgsdrv(Setting setting)
, (uint)(setting.outputDevice.SampleRate * setting.LatencySCCI / 1000)
, (uint)(setting.outputDevice.SampleRate * setting.outputDevice.WaitTime / 1000))) return false;
}
if (DriverPianoRoll != null)
{
if (!DriverPianoRoll.init(vgmBuf, chipRegister, EnmModel.PianoRollModel, new EnmChip[] { EnmChip.AY8910 }
, (uint)(setting.outputDevice.SampleRate * setting.LatencySCCI / 1000)
, (uint)(setting.outputDevice.SampleRate * setting.outputDevice.WaitTime / 1000))) return false;
}

//Play

Expand Down Expand Up @@ -3188,6 +3221,12 @@ public static bool MscPlay_mscdrv(Setting setting)
, (uint)(setting.outputDevice.SampleRate * setting.LatencySCCI / 1000)
, (uint)(setting.outputDevice.SampleRate * setting.outputDevice.WaitTime / 1000))) return false;
}
if (DriverPianoRoll != null)
{
if (!DriverPianoRoll.init(vgmBuf, chipRegister, EnmModel.PianoRollModel, new EnmChip[] { EnmChip.AY8910 }
, (uint)(setting.outputDevice.SampleRate * setting.LatencySCCI / 1000)
, (uint)(setting.outputDevice.SampleRate * setting.outputDevice.WaitTime / 1000))) return false;
}

//Play

Expand Down
26 changes: 15 additions & 11 deletions MDPlayer/MDPlayerx64/ChipRegister.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1739,9 +1739,13 @@ public void setYM2414Register(int chipID, int dPort, int dAddr, int dData, EnmMo



public void setAY8910Register(int chipID, int dAddr, int dData, EnmModel model)
public void setAY8910Register(int chipID, int dAddr, int dData, EnmModel model,long vgmFrameCounter)
{
if (model == EnmModel.PianoRollModel) return;
if (model == EnmModel.PianoRollModel)
{
pianoRollMng.SetRegister(EnmChip.AY8910, chipID, dAddr, dData, vgmFrameCounter);
return;
}

if (ctAY8910 == null) return;

Expand Down Expand Up @@ -2510,20 +2514,20 @@ public void softResetAY8910(int chipID, EnmModel model)
if (model == EnmModel.PianoRollModel) return;

// 全チャネルキーオフ
setAY8910Register(chipID, 0x07, 0x00, model);
setAY8910Register(chipID, 0x07, 0x00, model,0);

// ボリュームオフ
for (int ch = 0; ch < 3; ch++)
{
setAY8910Register(chipID, 0x8 + ch, 0x00, model);
setAY8910Register(chipID, 0x8 + ch, 0x00, model, 0);
}

//ノイズ初期化
setAY8910Register(chipID, 0x06, 0x00, model);
setAY8910Register(chipID, 0x06, 0x00, model, 0);
//エンベロープ初期化
setAY8910Register(chipID, 0x0b, 0x00, model);
setAY8910Register(chipID, 0x0c, 0x00, model);
setAY8910Register(chipID, 0x0d, 0x00, model);
setAY8910Register(chipID, 0x0b, 0x00, model, 0);
setAY8910Register(chipID, 0x0c, 0x00, model, 0);
setAY8910Register(chipID, 0x0d, 0x00, model, 0);
}

public void softResetYM2413(int chipID, EnmModel model)
Expand Down Expand Up @@ -4742,8 +4746,8 @@ public void setMaskAY8910(int chipID, int ch, bool mask)
{
maskPSGChAY8910[chipID][ch] = mask;

setAY8910Register(chipID, (byte)(0x8 + ch), (byte)psgRegisterAY8910[chipID][8 + ch], EnmModel.VirtualModel);
setAY8910Register(chipID, (byte)(0x8 + ch), (byte)psgRegisterAY8910[chipID][8 + ch], EnmModel.RealModel);
setAY8910Register(chipID, (byte)(0x8 + ch), (byte)psgRegisterAY8910[chipID][8 + ch], EnmModel.VirtualModel,0);
setAY8910Register(chipID, (byte)(0x8 + ch), (byte)psgRegisterAY8910[chipID][8 + ch], EnmModel.RealModel, 0);
}

public void setMaskRF5C164(int chipID, int ch, bool mask)
Expand Down Expand Up @@ -5273,7 +5277,7 @@ public void setFadeoutVolAY8910(int chipID, int v)
nowAY8910FadeoutVol[chipID] = v;
for (int c = 0; c < 3; c++)
{
setAY8910Register(chipID, 0x8 + c, psgRegisterAY8910[chipID][0x8 + c], EnmModel.RealModel);
setAY8910Register(chipID, 0x8 + c, psgRegisterAY8910[chipID][0x8 + c], EnmModel.RealModel, 0);
}
}

Expand Down
2 changes: 1 addition & 1 deletion MDPlayer/MDPlayerx64/Driver/AY/AY.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private uint GetUIntLE(byte[] buf, int ptr)

public void Setup(int songNum)
{
port port = new port();
port port = new port(this);
z80 = new Z80Processor
{
PortsSpace = port,
Expand Down
10 changes: 8 additions & 2 deletions MDPlayer/MDPlayerx64/Driver/AY/port.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public class port : IMemory
private byte CPCSw = 0;
private int BN = 0;
private int BP = 0;
private baseDriver driver;

public port(baseDriver driver)
{
this.driver = driver;
}

public byte this[int address]
{
Expand Down Expand Up @@ -71,7 +77,7 @@ private void OutPort(int address, byte value)
else if ((address & 0xc002) == 0x8000)
{
AYDat = value;
chipRegister.setAY8910Register(0, AYReg, AYDat, model);
chipRegister.setAY8910Register(0, AYReg, AYDat, model, driver.vgmFrameCounter);
AYRegMap[AYReg] = AYDat;
//Debug.WriteLine("AY Reg:{0:x02} Dat:{1:x02}", AYReg, AYDat);
}
Expand Down Expand Up @@ -122,7 +128,7 @@ private void CPCOutPort(byte value)

if (CPCSw == 0x80)
{
if (AYReg < 14) chipRegister.setAY8910Register(0, AYReg, AYDat, model);
if (AYReg < 14) chipRegister.setAY8910Register(0, AYReg, AYDat, model, driver.vgmFrameCounter);
CPCSw = 0;
}
}
Expand Down
2 changes: 1 addition & 1 deletion MDPlayer/MDPlayerx64/Driver/MGSDRV/MGSDRV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private void Run(byte[] vgmBuf)
z80.ClockSynchronizer = null;
z80.AutoStopOnRetWithStackEmpty = true;
z80.Memory = new MsxMemory(chipRegister, model);
z80.PortsSpace = new MsxPort(((MsxMemory)z80.Memory).slot, chipRegister, null, model);
z80.PortsSpace = new MsxPort(((MsxMemory)z80.Memory).slot, chipRegister, null, model,this);
z80.BeforeInstructionFetch += Z80OnBeforeInstructionFetch;

mapper = new Mapper((MapperRAMCartridge)((MsxMemory)z80.Memory).slot.slots[3][1], (MsxMemory)z80.Memory);
Expand Down
6 changes: 4 additions & 2 deletions MDPlayer/MDPlayerx64/Driver/MGSDRV/MsxPort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ public class MsxPort : IMemory
private EnmModel model;
private byte opllAdr;
private byte ay8910Adr;
private baseDriver driver;

public MsxPort(MSXSlot slot, ChipRegister chipRegister, MSXVDP vdp, EnmModel model)
public MsxPort(MSXSlot slot, ChipRegister chipRegister, MSXVDP vdp, EnmModel model, baseDriver driver)
{
this.slot = slot;
this.chipRegister = chipRegister;
this.vdp = vdp;
this.model = model;
this.driver = driver;
}

public byte this[int address]
Expand Down Expand Up @@ -59,7 +61,7 @@ private void OutPort(int address, byte value)
ay8910Adr = value;
break;
case 0xa1:
chipRegister?.setAY8910Register(0, ay8910Adr, value, model);
chipRegister?.setAY8910Register(0, ay8910Adr, value, model, driver.vgmFrameCounter);
break;
case 0xa2:
//log.Write("PSG Port Adr:{0:x04} Dat:{1:x02}", address, value);
Expand Down
2 changes: 1 addition & 1 deletion MDPlayer/MDPlayerx64/Driver/MuSICA/MuSICA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private void Run(byte[] vgmBuf)
AutoStopOnRetWithStackEmpty = true,
Memory = new MsxMemory(chipRegister, model)
};
z80.PortsSpace = new MsxPort(((MsxMemory)z80.Memory).slot, chipRegister, null, model);
z80.PortsSpace = new MsxPort(((MsxMemory)z80.Memory).slot, chipRegister, null, model, this);
z80.BeforeInstructionFetch += Z80OnBeforeInstructionFetch;

mapper = new Mapper((MapperRAMCartridge)((MsxMemory)z80.Memory).slot.slots[3][1], (MsxMemory)z80.Memory);
Expand Down
2 changes: 1 addition & 1 deletion MDPlayer/MDPlayerx64/Driver/MuSICA/MuSICA_K4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private void Run(byte[] msdBin, byte[] vcdBin)
AutoStopOnRetWithStackEmpty = true,
Memory = new MsxMemory(chipRegister, model)
};
z80.PortsSpace = new MsxPort(((MsxMemory)z80.Memory).slot, chipRegister, vdp, model);
z80.PortsSpace = new MsxPort(((MsxMemory)z80.Memory).slot, chipRegister, vdp, model, this);
z80.BeforeInstructionFetch += Z80OnBeforeInstructionFetch;
mapper = new Mapper((MapperRAMCartridge)((MsxMemory)z80.Memory).slot.slots[3][1], (MsxMemory)z80.Memory);
z80.Reset();
Expand Down
2 changes: 1 addition & 1 deletion MDPlayer/MDPlayerx64/Driver/NRTDRV/NRTDRV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ private void wpsg(byte d, byte a)
{
//Out(0x1c00, d);//PSG register
//Out(0x1b00, a);//PSG data
chipRegister.setAY8910Register(0, d, a, EnmModel.VirtualModel);
chipRegister.setAY8910Register(0, d, a, EnmModel.VirtualModel, vgmFrameCounter);
}
//else
//{
Expand Down
2 changes: 1 addition & 1 deletion MDPlayer/MDPlayerx64/Driver/S98/S98.cs
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ private void WriteYM3812(int chipID, byte adr, byte data)

private void WriteAY8910(int chipID, byte adr, byte data)
{
chipRegister.setAY8910Register(chipID, adr, data, model);
chipRegister.setAY8910Register(chipID, adr, data, model, vgmFrameCounter);
}

private void WriteSN76489(int chipID, byte data)
Expand Down
2 changes: 1 addition & 1 deletion MDPlayer/MDPlayerx64/Driver/vgm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ private void VcPSG()

private void VcAY8910()
{
chipRegister.setAY8910Register((vgmBuf[vgmAdr + 1] & 0x80) == 0 ? 0 : 1, vgmBuf[vgmAdr + 1] & 0x7f, vgmBuf[vgmAdr + 2], model);
chipRegister.setAY8910Register((vgmBuf[vgmAdr + 1] & 0x80) == 0 ? 0 : 1, vgmBuf[vgmAdr + 1] & 0x7f, vgmBuf[vgmAdr + 2], model, vgmFrameCounter);
//chipRegister.setAY8910Register(0, vgmBuf[vgmAdr + 1], vgmBuf[vgmAdr + 2], model);
vgmAdr += 3;
}
Expand Down
Loading

0 comments on commit 657850a

Please sign in to comment.