Skip to content

Commit

Permalink
Wの初期版
Browse files Browse the repository at this point in the history
  • Loading branch information
BouKiCHi committed Apr 15, 2020
1 parent ce422d6 commit 3861694
Show file tree
Hide file tree
Showing 6 changed files with 218 additions and 139 deletions.
2 changes: 1 addition & 1 deletion mucomDotNETCompiler/compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ private int SaveMub()
int length = mucInfo.bufDst.Count;
mubsize = length;

Log.WriteLine(LogLevel.INFO, "- mucom.NET -");
Log.WriteLine(LogLevel.INFO, "- mucomW.NET -");
Log.WriteLine(LogLevel.INFO, "[ Total count ]");
Log.WriteLine(LogLevel.INFO,strTcount);
Log.WriteLine(LogLevel.INFO, "[ Loop count ]");
Expand Down
21 changes: 15 additions & 6 deletions mucomDotNETCompiler/muc88.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ public class Muc88
public Msub msub = null;
public expand expand = null;

internal static readonly int MAXCH = 11;
/// <summary>
/// 最大チャンネル数
/// </summary>
internal static readonly int MAXCH = 22;
private readonly MUCInfo mucInfo;
private readonly Func<EnmFCOMPNextRtn>[] COMTBL;
//private readonly int errLin = 0;
Expand Down Expand Up @@ -1981,6 +1984,10 @@ private EnmFCOMPNextRtn SETR2()
n *= 4;

byte ch = (byte)work.COMNOW;

if (ch >= 11) ch -= 11;

// 範囲外(0未満、10超過) or SSG
if (ch < 0 || (ch >= 3 && ch < 7) || ch >= 10)
{
throw new MucException(
Expand Down Expand Up @@ -2843,14 +2850,17 @@ public int CWVC(int num, AutoExtendList<int> buf)

public ChannelType CHCHK()
{
if (work.COMNOW >= 3 && work.COMNOW < 6)
var CurrentChannel = work.COMNOW;
if (CurrentChannel >= 11) CurrentChannel -= 11;

if (CurrentChannel >= 3 && CurrentChannel < 6)
{
return ChannelType.SSG;
}

if (work.COMNOW == 6) return ChannelType.RHYTHM;
if (CurrentChannel == 6) return ChannelType.RHYTHM;

if (work.COMNOW < 10)
if (CurrentChannel < 10)
{
return ChannelType.FM;
}
Expand Down Expand Up @@ -2912,7 +2922,6 @@ internal int GetErrorLine()
internal int COMPIL()
{
work.COMNOW = 0;
work.MAXCH = 11;
work.ADRSTC = 0;
work.VPCO = 0;

Expand All @@ -2939,7 +2948,7 @@ internal int COMPIL()
public int COMPI3()
{
work.DATTBL = work.MU_TOP + 1;
work.MDATA = work.MU_TOP + 0x2f;// 11ch * 4byte + 3byte (DATTBLの大きさ?)
work.MDATA = work.MU_TOP + (MAXCH * 4) + 3;// 11ch * 4byte + 3byte (DATTBLの大きさ?)
work.REPCOUNT = 0;
work.title = work.titleFmt;

Expand Down
4 changes: 2 additions & 2 deletions mucomDotNETCompiler/work.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace mucomDotNET.Compiler
{
public static class work
{
public static int MAXCH = 11;
public static int MAXCH = 22;

//使用しない!
//public const int T_CLK = 0x8C10;
Expand Down Expand Up @@ -88,7 +88,7 @@ public static class work
public static int PSGMD { get; internal set; }
public static int KEYONR { get; internal set; }
public static int bufStartPtr { get; internal set; }
public static int[] bufCount { get; internal set; } = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
public static int[] bufCount { get; internal set; } = new int[MAXCH];
public static int JPCOL { get; internal set; }
public static List<int> JCHCOM { get; internal set; }

Expand Down
137 changes: 80 additions & 57 deletions mucomDotNETDriver/SoundWork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ public class SoundWork
,new CHDAT()//FM Ch6

,new CHDAT()//ADPCM Ch

// 2つ目
,new CHDAT()//FM Ch1
,new CHDAT()//FM Ch2
,new CHDAT()//FM Ch3

,new CHDAT()//SSG Ch1
,new CHDAT()//SSG Ch2
,new CHDAT()//SSG Ch3

,new CHDAT()//Drums Ch

,new CHDAT()//FM Ch4
,new CHDAT()//FM Ch5
,new CHDAT()//FM Ch6

,new CHDAT()//ADPCM Ch

};

public byte[] PREGBF = null;
Expand Down Expand Up @@ -82,6 +100,7 @@ public class SoundWork
public int NEWFNM { get; internal set; }
public ushort RANDUM { get; internal set; } = 0;
public int KEY_FLAG { get; internal set; } = 0;
public int PORTOFS { get; internal set; }

// ** PMS/AMS/LR DATA **
public byte[] PALDAT = new byte[] {
Expand Down Expand Up @@ -115,63 +134,9 @@ public class SoundWork
0x0F
};

internal void Init()
{
CHDAT[0].lengthCounter = 1;
CHDAT[0].instrumentNumber = 24;
CHDAT[0].volume = 10;

CHDAT[1].lengthCounter = 1;
CHDAT[1].instrumentNumber = 24;
CHDAT[1].volume = 10;
CHDAT[1].channelNumber = 1;

CHDAT[2].lengthCounter = 1;
CHDAT[2].instrumentNumber = 24;
CHDAT[2].volume = 10;
CHDAT[2].channelNumber = 2;


CHDAT[3].lengthCounter = 1;
CHDAT[3].instrumentNumber = 0;
CHDAT[3].volume = 8;
CHDAT[3].volReg = 8;
CHDAT[3].channelNumber = 0;

CHDAT[4].lengthCounter = 1;
CHDAT[4].instrumentNumber = 0;
CHDAT[4].volume = 8;
CHDAT[4].volReg = 9;
CHDAT[4].channelNumber = 2;

CHDAT[5].lengthCounter = 1;
CHDAT[5].instrumentNumber = 0;
CHDAT[5].volume = 8;
CHDAT[5].volReg = 10;
CHDAT[5].channelNumber = 4;


CHDAT[6].lengthCounter = 1;
CHDAT[6].volume = 10;
CHDAT[6].channelNumber = 2;


CHDAT[7].lengthCounter = 1;
CHDAT[7].volume = 10;
CHDAT[7].channelNumber = 2;

CHDAT[8].lengthCounter = 1;
CHDAT[8].volume = 10;
CHDAT[8].channelNumber = 2;

CHDAT[9].lengthCounter = 1;
CHDAT[9].volume = 10;
CHDAT[9].channelNumber = 2;


CHDAT[10].lengthCounter = 1;
CHDAT[10].volume = 10;
CHDAT[10].channelNumber = 2;
internal void Init() {
InitValue(0);
InitValue(11);

PREGBF = new byte[9];
INITPM = new byte[] { 0, 0, 0, 0, 0, 56, 0, 0, 0 };
Expand Down Expand Up @@ -221,6 +186,64 @@ internal void Init()
};

}

private void InitValue(int ofs) {
CHDAT[ofs + 0].lengthCounter = 1;
CHDAT[ofs + 0].instrumentNumber = 24;
CHDAT[ofs + 0].volume = 10;

CHDAT[ofs + 1].lengthCounter = 1;
CHDAT[ofs + 1].instrumentNumber = 24;
CHDAT[ofs + 1].volume = 10;
CHDAT[ofs + 1].channelNumber = 1;

CHDAT[ofs + 2].lengthCounter = 1;
CHDAT[ofs + 2].instrumentNumber = 24;
CHDAT[ofs + 2].volume = 10;
CHDAT[ofs + 2].channelNumber = 2;


CHDAT[ofs + 3].lengthCounter = 1;
CHDAT[ofs + 3].instrumentNumber = 0;
CHDAT[ofs + 3].volume = 8;
CHDAT[ofs + 3].volReg = 8;
CHDAT[ofs + 3].channelNumber = 0;

CHDAT[ofs + 4].lengthCounter = 1;
CHDAT[ofs + 4].instrumentNumber = 0;
CHDAT[ofs + 4].volume = 8;
CHDAT[ofs + 4].volReg = 9;
CHDAT[ofs + 4].channelNumber = 2;

CHDAT[ofs + 5].lengthCounter = 1;
CHDAT[ofs + 5].instrumentNumber = 0;
CHDAT[ofs + 5].volume = 8;
CHDAT[ofs + 5].volReg = 10;
CHDAT[ofs + 5].channelNumber = 4;


CHDAT[ofs + 6].lengthCounter = 1;
CHDAT[ofs + 6].volume = 10;
CHDAT[ofs + 6].channelNumber = 2;


CHDAT[ofs + 7].lengthCounter = 1;
CHDAT[ofs + 7].volume = 10;
CHDAT[ofs + 7].channelNumber = 2;

CHDAT[ofs + 8].lengthCounter = 1;
CHDAT[ofs + 8].volume = 10;
CHDAT[ofs + 8].channelNumber = 2;

CHDAT[ofs + 9].lengthCounter = 1;
CHDAT[ofs + 9].volume = 10;
CHDAT[ofs + 9].channelNumber = 2;


CHDAT[ofs + 10].lengthCounter = 1;
CHDAT[ofs + 10].volume = 10;
CHDAT[ofs + 10].channelNumber = 2;
}
}

public class CHDAT
Expand Down
Loading

0 comments on commit 3861694

Please sign in to comment.