Skip to content

Commit

Permalink
TAG010 2020/01/28
Browse files Browse the repository at this point in the history
  Compiler
    ・Lが無いとコンパイルに失敗するバグを修正
  Player
    ・オートパンを実装
  • Loading branch information
kumatan committed Jan 27, 2020
1 parent 9bda121 commit fdb1e9d
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
�X�V����
TAG010 2020/01/28
Compiler
�EL�������ƃR���p�C���Ɏ��s����o�O���C��
Player
�E�I�[�g�p��������

TAG009 2020/01/27
Player
�ESSG�̃��o�[�u�̃o�O���C��
Expand Down
1 change: 1 addition & 0 deletions mucomDotNETCompiler/lang/message.ja-JP.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ W0411='VM'コマンドの値が0の時に音量(246以上251以下)が指定さ
W0412=SSGパートで't'又は'T'コマンドを使用した場合、その値は指定時点で変わるのではなく、曲全体のテンポが変わります。
W0413=!!注意!! timer-Bの設定値に253以上255以下の値を設定しています。(ドライバがハングします!)
W0414=ポルタメントで、クロック129以上が指定されています。(値:{0})
W0415=オートパンで、値1が4未満で指定されています。(値1:{0})
E0400=未定義のマクロを呼び出そうとしています。
E0401=マクロ行から復帰できませんでした。(アドレスオーバー)
E0402=マクロ行から復帰できませんでした。(アドレス未定義)
Expand Down
1 change: 1 addition & 0 deletions mucomDotNETCompiler/lang/message.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ W0411=Volume (246 to 251 or less) was specified when the VM command value was 0.
W0412=If you use the 't' or 'T' command in the SSG part, the tempo of the entire song changes, not at the specified time.
W0413=!!Caution!! The timer-B setting value is 253 to 255 or less. (Driver hang up!)
W0414=Portamento specifies a clock of 129 or higher. (Value:{0})
W0415=AutoPanning specifies a clock of 3 or lower. (Value:{0})
E0400=Trying to call undefined macro!
E0401=Unable to return from macro line.(Address Exceeded)
E0402=Unable to return from macro line.(Address Undefined)
Expand Down
20 changes: 19 additions & 1 deletion mucomDotNETCompiler/muc88.cs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,24 @@ private EnmFCOMPNextRtn SETLR()

msub.MWRITE(new MubDat(0xf8), new MubDat((byte)n));// COM OF 'p'

////
//AMD98
char c = mucInfo.lin.Item2.Length > mucInfo.srcCPtr ? mucInfo.lin.Item2[mucInfo.srcCPtr] : (char)0;
if (c == ',')//0x2c
{
if (n < 4)
{
WriteWarning(msg.get("W0415"), mucInfo.row, mucInfo.col);
}

mucInfo.srcCPtr++;
ptr = mucInfo.srcCPtr;
n = msub.REDATA(mucInfo.lin, ref ptr);
mucInfo.srcCPtr = ptr;
msub.MWRIT2(new MubDat((byte)n));// 2こめ
}
////

return EnmFCOMPNextRtn.fcomp1;
}

Expand Down Expand Up @@ -2468,7 +2486,7 @@ public void CMPEND()
{
mucInfo.ErrSign = false;

if (work.tcnt[work.COMNOW] != 0)
if (work.tcnt[work.COMNOW] != 0 && mucInfo.bufDst.Get(work.DATTBL + 4 * work.COMNOW + 2)!=null)
{
goto CMPE2;
}
Expand Down
6 changes: 6 additions & 0 deletions mucomDotNETDriver/SoundWork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class SoundWork
public byte LFOP6_VAL { get; internal set; }
public byte FLGADR { get; internal set; }
public int NEWFNM { get; internal set; }
public ushort RANDUM { get; internal set; } = 0;

// ** PMS/AMS/LR DATA **
public byte[] PALDAT = new byte[] {
Expand Down Expand Up @@ -254,5 +255,10 @@ public class CHDAT
public int returnAddress = 0;//DW 0 ; リターンアドレス 34,35
public int reserve = 0;//DB 0,0 ; 36,37 (アキ)

public byte panEnable = 0;//DB ? ;パーン 38
public byte panMode = 0;//DB ? ;パーン モード 39
public byte panCounter1 = 0;//DB ? ;パーン カウンター 40
public byte panCounter2 = 0;//DB ? ;パーン カウンター 41
public byte panValue = 0;//DB ? ;パーン 値 42
}
}
130 changes: 126 additions & 4 deletions mucomDotNETDriver/music2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public void SetFMCOMTable()
,REPSTF// 0xF5 - REPEAT START SET '['
,REPENF// 0xF6 - REPEAT END SET ']'
,MDSET // 0xF7 - FMオンゲン モードセット
,STEREO// 0xF8 - STEREO MODE
// ,STEREO// 0xF8 - STEREO MODE
,STEREO_AMD98 // 0xF8 - STEREO MODE
,FLGSET// 0xF9 - FLAG SET
,W_REG // 0xFA - COMMAND OF 'y'
,VOLUPF// 0xFB - VOLUME UP ')'
Expand Down Expand Up @@ -484,11 +485,15 @@ public void DRIVE()

public void FMENT(int ix)
{
work.idx = ix;
work.cd = work.soundWork.CHDAT[work.idx];

PANNING();//AMD98

if (work.soundWork.CHDAT[ix].muteFlg) //KUMA: 0x08(bit3)=MUTE FLAG
{
work.soundWork.READY = 0x00;
}
work.idx = ix;
FMSUB();
PLLFO();
if (work.soundWork.CHDAT[ix].muteFlg)//KUMA: 0x08(bit3)=MUTE FLAG
Expand Down Expand Up @@ -517,8 +522,6 @@ public void SSGENT(int ix)

public void FMSUB()
{
work.cd = work.soundWork.CHDAT[work.idx];

//work.carry = false;
work.cd.lengthCounter--;
work.cd.lengthCounter = (byte)work.cd.lengthCounter;
Expand Down Expand Up @@ -1336,6 +1339,125 @@ public void STEREO()
PSGOUT((byte)(dat + 0x18), a);
}

public void STEREO_AMD98()
{
byte a,c,d;
if (work.soundWork.DRMF1 != 0)
{
goto STE020;
}

if (work.soundWork.PCMFLG != 0)
{
work.soundWork.PCMLR = work.mData[work.hl++].dat;
return;
}

a = work.mData[work.hl++].dat;
if (a >= 4)
{
goto STE012;
}

//既存処理
c = (byte)(((a >> 2) & 0x3f) | (a << 6));//右ローテート2回(左6回のほうがC#的にはシンプル)
d = work.soundWork.PALDAT[work.soundWork.FMPORT + work.cd.channelNumber];
d = (byte)((d & 0b0011_1111) | c);
work.soundWork.PALDAT[work.soundWork.FMPORT + work.cd.channelNumber] = d;
a = (byte)(0x0B4 + work.cd.channelNumber);
PSGOUT(a, d);
work.cd.panEnable = 0;//パーン禁止
return;

STE012:
work.cd.panEnable |= 1;//パーン許可
work.cd.panMode = a;
work.cd.panCounter1 = work.mData[work.hl].dat;
work.cd.panCounter2 = work.mData[work.hl].dat;
work.hl++;
if (a == 4)
{
work.cd.panValue = 2;
}
else if (a == 5)
{
work.cd.panValue = 1;
}
else
{
work.cd.panValue = 3;
}
c = (byte)(((a >> 2) & 0x3f) | (a << 6));//右ローテート2回(左6回のほうがC#的にはシンプル)
d = work.soundWork.PALDAT[work.soundWork.FMPORT + work.cd.channelNumber];
d = (byte)((d & 0b0011_1111) | c);
work.soundWork.PALDAT[work.soundWork.FMPORT + work.cd.channelNumber] = d;
a = (byte)(0x0B4 + work.cd.channelNumber);
PSGOUT(a, d);
return;

STE020:
byte dat = work.mData[work.hl++].dat;
c = dat;
dat &= 0b0000_1111;
a = work.soundWork.DRMVOL[dat];
a = (byte)(((c << 2) & 0b1100_0000) | (a & 0b0001_1111));
work.soundWork.DRMVOL[dat] = a;
PSGOUT((byte)(dat + 0x18), a);
}

public void PANNING()
{
if ((work.cd.panEnable & 1) == 0) return;
if ((--work.cd.panCounter1) != 0) return;

work.cd.panCounter1 = work.cd.panCounter2;//; カウンター再設定

if (work.cd.panMode == 4)
{
//LEFT
byte ah = work.cd.panValue;
if (ah >= 3)
{
ah = 0;
}
ah++;
work.cd.panValue = ah;//ah : 1~3
}
else if (work.cd.panMode == 5)
{
//RIGHT
byte ah = work.cd.panValue;
ah--;
if (ah == 0)
{
ah = 3;
}
work.cd.panValue = ah;//ah : 1~3
}
else
{
//RANDOM
ushort ax;
do
{
ax = work.soundWork.RANDUM;
ax *= 5;
ax += 0x1993;
work.soundWork.RANDUM = ax;
ax &= 0x0300;
} while (ax == 0);
work.cd.panValue = (byte)(ax >> 8);//ah : 1~3
}

byte a = work.cd.panValue;
byte c = (byte)(((a >> 2) & 0x3f) | (a << 6));//右ローテート2回(左6回のほうがC#的にはシンプル)
byte d = work.soundWork.PALDAT[work.soundWork.FMPORT + work.cd.channelNumber];
d = (byte)((d & 0b0011_1111) | c);
work.soundWork.PALDAT[work.soundWork.FMPORT + work.cd.channelNumber] = d;
a = (byte)(0x0B4 + work.cd.channelNumber);
PSGOUT(a, d);
}

// ** フラグセット**

public void FLGSET()
Expand Down

0 comments on commit fdb1e9d

Please sign in to comment.