Add code
This commit is contained in:
parent
caf33d2dc8
commit
e53c129ff7
2 changed files with 968 additions and 0 deletions
56
Program.cs
Normal file
56
Program.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
using static SAMSharp.Sam;
|
||||
using static SAMSharp.Reciter;
|
||||
using System;
|
||||
using System.Media;
|
||||
|
||||
namespace SAMSharp
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static Stream Wave(byte[] buffer, int bufferlength)
|
||||
{
|
||||
var strm = new MemoryStream();
|
||||
var writer = new BinaryWriter(strm);
|
||||
|
||||
writer.Write("RIFF".ToCharArray());
|
||||
writer.Write(bufferlength + 28);
|
||||
writer.Write("WAVEfmt ".ToCharArray());
|
||||
|
||||
writer.Write(16);
|
||||
writer.Write((short)1);
|
||||
writer.Write((short)1);
|
||||
|
||||
writer.Write(22050);
|
||||
writer.Write(22050);
|
||||
|
||||
writer.Write((short)1);
|
||||
writer.Write((short)8);
|
||||
|
||||
//data chunk
|
||||
writer.Write("data".ToCharArray());
|
||||
writer.Write(bufferlength);
|
||||
|
||||
writer.Write(buffer, 0, bufferlength);
|
||||
|
||||
return strm;
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
string txt = null;
|
||||
foreach (var arg in args)
|
||||
txt += $"{arg} ";
|
||||
byte[] text = Encoding.ASCII.GetBytes(txt);
|
||||
Array.Resize(ref text, 256);
|
||||
TextToPhonemes(text);
|
||||
SetInput(text);
|
||||
SAMMain();
|
||||
var strm = Wave(GetBuffer(), GetBufferLength() / 50);
|
||||
strm.Position = 0;
|
||||
new SoundPlayer(strm).PlaySync();
|
||||
}
|
||||
}
|
||||
}
|
912
Reciter.cs
Normal file
912
Reciter.cs
Normal file
|
@ -0,0 +1,912 @@
|
|||
namespace SAMSharp
|
||||
{
|
||||
class Reciter
|
||||
{
|
||||
//some flags
|
||||
static byte[] tab36376 =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, // 0-7
|
||||
0, 0, 0, 0, 0, 0, 0, 0, // 8-15
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 2, 2, 2, 2, 2, 2, 130, // ' ', '!'
|
||||
0, 0, 2, 2, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 2, 2, 2, 2, 2, 2,
|
||||
2, 192, 168, 176, 172, 192, 160, 184, // '@', 'A'
|
||||
160, 192, 188, 160, 172, 168, 172, 192,
|
||||
160, 160, 172, 180, 164, 192, 168, 168,
|
||||
176, 192, 188, 0, 0, 0, 2, 0, // 'X', 'Y', 'Z', '[',
|
||||
32, 32, 155, 32, 192, 185, 32, 205,
|
||||
163, 76, 138, 142
|
||||
};
|
||||
|
||||
static char[] rules =
|
||||
{
|
||||
']',(char)('A'|0x80),
|
||||
' ','(','A','.',')', '=','E','H','4','Y','.',(char)(' '|0x80),
|
||||
'(','A',')',' ', '=','A',(char)('H'|0x80),
|
||||
' ','(','A','R','E',')',' ', '=','A','A',(char)('R'|0x80),
|
||||
' ','(','A','R',')','O', '=','A','X',(char)('R'|0x80),
|
||||
'(','A','R',')','#', '=','E','H','4',(char)('R'|0x80),
|
||||
' ','^','(','A','S',')','#', '=','E','Y','4',(char)('S'|0x80),
|
||||
'(','A',')','W','A', '=','A',(char)('X'|0x80),
|
||||
'(','A','W',')', '=','A','O',(char)('5'|0x80),
|
||||
' ',':','(','A','N','Y',')', '=','E','H','4','N','I',(char)('Y'|0x80),
|
||||
'(','A',')','^','+','#', '=','E','Y',(char)('5'|0x80),
|
||||
'#',':','(','A','L','L','Y',')', '=','U','L','I',(char)('Y'|0x80),
|
||||
' ','(','A','L',')','#', '=','U',(char)('L'|0x80),
|
||||
'(','A','G','A','I','N',')', '=','A','X','G','E','H','4',(char)('N'|0x80),
|
||||
'#',':','(','A','G',')','E', '=','I','H',(char)('J'|0x80),
|
||||
'(','A',')','^','%', '=','E',(char)('Y'|0x80),
|
||||
'(','A',')','^','+',':','#', '=','A',(char)('E'|0x80),
|
||||
' ',':','(','A',')','^','+',' ', '=','E','Y',(char)('4'|0x80),
|
||||
' ','(','A','R','R',')', '=','A','X',(char)('R'|0x80),
|
||||
'(','A','R','R',')', '=','A','E','4',(char)('R'|0x80),
|
||||
' ','^','(','A','R',')',' ', '=','A','A','5',(char)('R'|0x80),
|
||||
'(','A','R',')', '=','A','A','5',(char)('R'|0x80),
|
||||
'(','A','I','R',')', '=','E','H','4',(char)('R'|0x80),
|
||||
'(','A','I',')', '=','E','Y',(char)('4'|0x80),
|
||||
'(','A','Y',')', '=','E','Y',(char)('5'|0x80),
|
||||
'(','A','U',')', '=','A','O',(char)('4'|0x80),
|
||||
'#',':','(','A','L',')',' ', '=','U',(char)('L'|0x80),
|
||||
'#',':','(','A','L','S',')',' ', '=','U','L',(char)('Z'|0x80),
|
||||
'(','A','L','K',')', '=','A','O','4',(char)('K'|0x80),
|
||||
'(','A','L',')','^', '=','A','O',(char)('L'|0x80),
|
||||
' ',':','(','A','B','L','E',')', '=','E','Y','4','B','U',(char)('L'|0x80),
|
||||
'(','A','B','L','E',')', '=','A','X','B','U',(char)('L'|0x80),
|
||||
'(','A',')','V','O', '=','E','Y',(char)('4'|0x80),
|
||||
'(','A','N','G',')','+', '=','E','Y','4','N',(char)('J'|0x80),
|
||||
'(','A','T','A','R','I',')', '=','A','H','T','A','A','4','R','I',(char)('Y'|0x80),
|
||||
'(','A',')','T','O','M', '=','A',(char)('E'|0x80),
|
||||
'(','A',')','T','T','I', '=','A',(char)('E'|0x80),
|
||||
' ','(','A','T',')',' ', '=','A','E',(char)('T'|0x80),
|
||||
' ','(','A',')','T', '=','A',(char)('H'|0x80),
|
||||
'(','A',')', '=','A',(char)('E'|0x80),
|
||||
|
||||
']',(char)('B'|0x80),
|
||||
' ','(','B',')',' ', '=','B','I','Y',(char)('4'|0x80),
|
||||
' ','(','B','E',')','^','#', '=','B','I',(char)('H'|0x80),
|
||||
'(','B','E','I','N','G',')', '=','B','I','Y','4','I','H','N',(char)('X'|0x80),
|
||||
' ','(','B','O','T','H',')',' ', '=','B','O','W','4','T',(char)('H'|0x80),
|
||||
' ','(','B','U','S',')','#', '=','B','I','H','4',(char)('Z'|0x80),
|
||||
'(','B','R','E','A','K',')', '=','B','R','E','Y','5',(char)('K'|0x80),
|
||||
'(','B','U','I','L',')', '=','B','I','H','4',(char)('L'|0x80),
|
||||
'(','B',')', '=',(char)('B'|0x80),
|
||||
|
||||
']',(char)('C'|0x80),
|
||||
' ','(','C',')',' ', '=','S','I','Y',(char)('4'|0x80),
|
||||
' ','(','C','H',')','^', '=',(char)('K'|0x80),
|
||||
'^','E','(','C','H',')', '=',(char)('K'|0x80),
|
||||
'(','C','H','A',')','R','#', '=','K','E','H',(char)('5'|0x80),
|
||||
'(','C','H',')', '=','C',(char)('H'|0x80),
|
||||
' ','S','(','C','I',')','#', '=','S','A','Y',(char)('4'|0x80),
|
||||
'(','C','I',')','A', '=','S',(char)('H'|0x80),
|
||||
'(','C','I',')','O', '=','S',(char)('H'|0x80),
|
||||
'(','C','I',')','E','N', '=','S',(char)('H'|0x80),
|
||||
'(','C','I','T','Y',')', '=','S','I','H','T','I',(char)('Y'|0x80),
|
||||
'(','C',')','+', '=',(char)('S'|0x80),
|
||||
'(','C','K',')', '=',(char)('K'|0x80),
|
||||
'(','C','O','M','M','O','D','O','R','E',')','=','K','A','A','4','M','A','H','D','O','H',(char)('R'|0x80),
|
||||
'(','C','O','M',')', '=','K','A','H',(char)('M'|0x80),
|
||||
'(','C','U','I','T',')', '=','K','I','H',(char)('T'|0x80),
|
||||
'(','C','R','E','A',')', '=','K','R','I','Y','E',(char)('Y'|0x80),
|
||||
'(','C',')', '=',(char)('K'|0x80),
|
||||
|
||||
']',(char)('D'|0x80),
|
||||
' ','(','D',')',' ', '=','D','I','Y',(char)('4'|0x80),
|
||||
' ','(','D','R','.',')',' ', '=','D','A','A','4','K','T','E',(char)('R'|0x80),
|
||||
'#',':','(','D','E','D',')',' ', '=','D','I','H',(char)('D'|0x80),
|
||||
'.','E','(','D',')',' ', '=',(char)('D'|0x80),
|
||||
'#',':','^','E','(','D',')',' ', '=',(char)('T'|0x80),
|
||||
' ','(','D','E',')','^','#', '=','D','I',(char)('H'|0x80),
|
||||
' ','(','D','O',')',' ', '=','D','U',(char)('W'|0x80),
|
||||
' ','(','D','O','E','S',')', '=','D','A','H',(char)('Z'|0x80),
|
||||
'(','D','O','N','E',')',' ', '=','D','A','H','5',(char)('N'|0x80),
|
||||
'(','D','O','I','N','G',')', '=','D','U','W','4','I','H','N',(char)('X'|0x80),
|
||||
' ','(','D','O','W',')', '=','D','A',(char)('W'|0x80),
|
||||
'#','(','D','U',')','A', '=','J','U',(char)('W'|0x80),
|
||||
'#','(','D','U',')','^','#', '=','J','A',(char)('X'|0x80),
|
||||
'(','D',')', '=',(char)('D'|0x80),
|
||||
|
||||
']',(char)('E'|0x80),
|
||||
' ','(','E',')',' ', '=','I','Y','I','Y',(char)('4'|0x80),
|
||||
'#',':','(','E',')',' ',(char)('='|0x80),
|
||||
'\'',':','^','(','E',')',' ',(char)('='|0x80),
|
||||
' ',':','(','E',')',' ', '=','I',(char)('Y'|0x80),
|
||||
'#','(','E','D',')',' ', '=',(char)('D'|0x80),
|
||||
'#',':','(','E',')','D',' ',(char)('='|0x80),
|
||||
'(','E','V',')','E','R', '=','E','H','4',(char)('V'|0x80),
|
||||
'(','E',')','^','%', '=','I','Y',(char)('4'|0x80),
|
||||
'(','E','R','I',')','#', '=','I','Y','4','R','I',(char)('Y'|0x80),
|
||||
'(','E','R','I',')', '=','E','H','4','R','I',(char)('H'|0x80),
|
||||
'#',':','(','E','R',')','#', '=','E',(char)('R'|0x80),
|
||||
'(','E','R','R','O','R',')', '=','E','H','4','R','O','H',(char)('R'|0x80),
|
||||
'(','E','R','A','S','E',')', '=','I','H','R','E','Y','5',(char)('S'|0x80),
|
||||
'(','E','R',')','#', '=','E','H',(char)('R'|0x80),
|
||||
'(','E','R',')', '=','E',(char)('R'|0x80),
|
||||
' ','(','E','V','E','N',')', '=','I','Y','V','E','H',(char)('N'|0x80),
|
||||
'#',':','(','E',')','W',(char)('='|0x80),
|
||||
'@','(','E','W',')', '=','U',(char)('W'|0x80),
|
||||
'(','E','W',')', '=','Y','U',(char)('W'|0x80),
|
||||
'(','E',')','O', '=','I',(char)('Y'|0x80),
|
||||
'#',':','&','(','E','S',')',' ', '=','I','H',(char)('Z'|0x80),
|
||||
'#',':','(','E',')','S',' ',(char)('='|0x80),
|
||||
'#',':','(','E','L','Y',')',' ', '=','L','I',(char)('Y'|0x80),
|
||||
'#',':','(','E','M','E','N','T',')', '=','M','E','H','N',(char)('T'|0x80),
|
||||
'(','E','F','U','L',')', '=','F','U','H',(char)('L'|0x80),
|
||||
'(','E','E',')', '=','I','Y',(char)('4'|0x80),
|
||||
'(','E','A','R','N',')', '=','E','R','5',(char)('N'|0x80),
|
||||
' ','(','E','A','R',')','^', '=','E','R',(char)('5'|0x80),
|
||||
'(','E','A','D',')', '=','E','H',(char)('D'|0x80),
|
||||
'#',':','(','E','A',')',' ', '=','I','Y','A',(char)('X'|0x80),
|
||||
'(','E','A',')','S','U', '=','E','H',(char)('5'|0x80),
|
||||
'(','E','A',')', '=','I','Y',(char)('5'|0x80),
|
||||
'(','E','I','G','H',')', '=','E','Y',(char)('4'|0x80),
|
||||
'(','E','I',')', '=','I','Y',(char)('4'|0x80),
|
||||
' ','(','E','Y','E',')', '=','A','Y',(char)('4'|0x80),
|
||||
'(','E','Y',')', '=','I',(char)('Y'|0x80),
|
||||
'(','E','U',')', '=','Y','U','W',(char)('5'|0x80),
|
||||
'(','E','Q','U','A','L',')', '=','I','Y','4','K','W','U',(char)('L'|0x80),
|
||||
'(','E',')', '=','E',(char)('H'|0x80),
|
||||
|
||||
']',(char)('F'|0x80),
|
||||
' ','(','F',')',' ', '=','E','H','4',(char)('F'|0x80),
|
||||
'(','F','U','L',')', '=','F','U','H',(char)('L'|0x80),
|
||||
'(','F','R','I','E','N','D',')', '=','F','R','E','H','5','N',(char)('D'|0x80),
|
||||
'(','F','A','T','H','E','R',')', '=','F','A','A','4','D','H','E',(char)('R'|0x80),
|
||||
'(','F',')','F',(char)('='|0x80),
|
||||
'(','F',')', '=',(char)('F'|0x80),
|
||||
|
||||
']',(char)('G'|0x80),
|
||||
' ','(','G',')',' ', '=','J','I','Y',(char)('4'|0x80),
|
||||
'(','G','I','V',')', '=','G','I','H','5',(char)('V'|0x80),
|
||||
' ','(','G',')','I','^', '=',(char)('G'|0x80),
|
||||
'(','G','E',')','T', '=','G','E','H',(char)('5'|0x80),
|
||||
'S','U','(','G','G','E','S',')', '=','G','J','E','H','4',(char)('S'|0x80),
|
||||
'(','G','G',')', '=',(char)('G'|0x80),
|
||||
' ','B','#','(','G',')', '=',(char)('G'|0x80),
|
||||
'(','G',')','+', '=',(char)('J'|0x80),
|
||||
'(','G','R','E','A','T',')', '=','G','R','E','Y','4',(char)('T'|0x80),
|
||||
'(','G','O','N',')','E', '=','G','A','O','5',(char)('N'|0x80),
|
||||
'#','(','G','H',')',(char)('='|0x80),
|
||||
' ','(','G','N',')', '=',(char)('N'|0x80),
|
||||
'(','G',')', '=',(char)('G'|0x80),
|
||||
|
||||
']',(char)('H'|0x80),
|
||||
' ','(','H',')',' ', '=','E','Y','4','C',(char)('H'|0x80),
|
||||
' ','(','H','A','V',')', '=','/','H','A','E','6',(char)('V'|0x80),
|
||||
' ','(','H','E','R','E',')', '=','/','H','I','Y',(char)('R'|0x80),
|
||||
' ','(','H','O','U','R',')', '=','A','W','5','E',(char)('R'|0x80),
|
||||
'(','H','O','W',')', '=','/','H','A',(char)('W'|0x80),
|
||||
'(','H',')','#', '=','/',(char)('H'|0x80),
|
||||
'(','H',')',(char)('='|0x80),
|
||||
|
||||
']',(char)('I'|0x80),
|
||||
' ','(','I','N',')', '=','I','H',(char)('N'|0x80),
|
||||
' ','(','I',')',' ', '=','A','Y',(char)('4'|0x80),
|
||||
'(','I',')',' ', '=','A',(char)('Y'|0x80),
|
||||
'(','I','N',')','D', '=','A','Y','5',(char)('N'|0x80),
|
||||
'S','E','M','(','I',')', '=','I',(char)('Y'|0x80),
|
||||
' ','A','N','T','(','I',')', '=','A',(char)('Y'|0x80),
|
||||
'(','I','E','R',')', '=','I','Y','E',(char)('R'|0x80),
|
||||
'#',':','R','(','I','E','D',')',' ', '=','I','Y',(char)('D'|0x80),
|
||||
'(','I','E','D',')',' ', '=','A','Y','5',(char)('D'|0x80),
|
||||
'(','I','E','N',')', '=','I','Y','E','H',(char)('N'|0x80),
|
||||
'(','I','E',')','T', '=','A','Y','4','E',(char)('H'|0x80),
|
||||
'(','I','\'',')', '=','A','Y',(char)('5'|0x80),
|
||||
' ',':','(','I',')','^','%', '=','A','Y',(char)('5'|0x80),
|
||||
' ',':','(','I','E',')',' ', '=','A','Y',(char)('4'|0x80),
|
||||
'(','I',')','%', '=','I',(char)('Y'|0x80),
|
||||
'(','I','E',')', '=','I','Y',(char)('4'|0x80),
|
||||
' ','(','I','D','E','A',')', '=','A','Y','D','I','Y','5','A',(char)('H'|0x80),
|
||||
'(','I',')','^','+',':','#', '=','I',(char)('H'|0x80),
|
||||
'(','I','R',')','#', '=','A','Y',(char)('R'|0x80),
|
||||
'(','I','Z',')','%', '=','A','Y',(char)('Z'|0x80),
|
||||
'(','I','S',')','%', '=','A','Y',(char)('Z'|0x80),
|
||||
'I','^','(','I',')','^','#', '=','I',(char)('H'|0x80),
|
||||
'+','^','(','I',')','^','+', '=','A',(char)('Y'|0x80),
|
||||
'#',':','^','(','I',')','^','+', '=','I',(char)('H'|0x80),
|
||||
'(','I',')','^','+', '=','A',(char)('Y'|0x80),
|
||||
'(','I','R',')', '=','E',(char)('R'|0x80),
|
||||
'(','I','G','H',')', '=','A','Y',(char)('4'|0x80),
|
||||
'(','I','L','D',')', '=','A','Y','5','L',(char)('D'|0x80),
|
||||
' ','(','I','G','N',')', '=','I','H','G',(char)('N'|0x80),
|
||||
'(','I','G','N',')',' ', '=','A','Y','4',(char)('N'|0x80),
|
||||
'(','I','G','N',')','^', '=','A','Y','4',(char)('N'|0x80),
|
||||
'(','I','G','N',')','%', '=','A','Y','4',(char)('N'|0x80),
|
||||
'(','I','C','R','O',')', '=','A','Y','4','K','R','O',(char)('H'|0x80),
|
||||
'(','I','Q','U','E',')', '=','I','Y','4',(char)('K'|0x80),
|
||||
'(','I',')', '=','I',(char)('H'|0x80),
|
||||
|
||||
']',(char)('J'|0x80),
|
||||
' ','(','J',')',' ', '=','J','E','Y',(char)('4'|0x80),
|
||||
'(','J',')', '=',(char)('J'|0x80),
|
||||
|
||||
']',(char)('K'|0x80),
|
||||
' ','(','K',')',' ', '=','K','E','Y',(char)('4'|0x80),
|
||||
' ','(','K',')','N',(char)('='|0x80),
|
||||
'(','K',')', '=',(char)('K'|0x80),
|
||||
|
||||
']',(char)('L'|0x80),
|
||||
' ','(','L',')',' ', '=','E','H','4',(char)('L'|0x80),
|
||||
'(','L','O',')','C','#', '=','L','O',(char)('W'|0x80),
|
||||
'L','(','L',')',(char)('='|0x80),
|
||||
'#',':','^','(','L',')','%', '=','U',(char)('L'|0x80),
|
||||
'(','L','E','A','D',')', '=','L','I','Y',(char)('D'|0x80),
|
||||
' ','(','L','A','U','G','H',')', '=','L','A','E','4',(char)('F'|0x80),
|
||||
'(','L',')', '=',(char)('L'|0x80),
|
||||
|
||||
']',(char)('M'|0x80),
|
||||
' ','(','M',')',' ', '=','E','H','4',(char)('M'|0x80),
|
||||
' ','(','M','R','.',')',' ', '=','M','I','H','4','S','T','E',(char)('R'|0x80),
|
||||
' ','(','M','S','.',')', '=','M','I','H','5',(char)('Z'|0x80),
|
||||
' ','(','M','R','S','.',')',' ', '=','M','I','H','4','S','I','X',(char)('Z'|0x80),
|
||||
'(','M','O','V',')', '=','M','U','W','4',(char)('V'|0x80),
|
||||
'(','M','A','C','H','I','N',')', '=','M','A','H','S','H','I','Y','5',(char)('N'|0x80),
|
||||
'M','(','M',')',(char)('='|0x80),
|
||||
'(','M',')', '=',(char)('M'|0x80),
|
||||
|
||||
']',(char)('N'|0x80),
|
||||
' ','(','N',')',' ', '=','E','H','4',(char)('N'|0x80),
|
||||
'E','(','N','G',')','+', '=','N',(char)('J'|0x80),
|
||||
'(','N','G',')','R', '=','N','X',(char)('G'|0x80),
|
||||
'(','N','G',')','#', '=','N','X',(char)('G'|0x80),
|
||||
'(','N','G','L',')','%', '=','N','X','G','U',(char)('L'|0x80),
|
||||
'(','N','G',')', '=','N',(char)('X'|0x80),
|
||||
'(','N','K',')', '=','N','X',(char)('K'|0x80),
|
||||
' ','(','N','O','W',')',' ', '=','N','A','W',(char)('4'|0x80),
|
||||
'N','(','N',')',(char)('='|0x80),
|
||||
'(','N','O','N',')','E', '=','N','A','H','4',(char)('N'|0x80),
|
||||
'(','N',')', '=',(char)('N'|0x80),
|
||||
|
||||
']',(char)('O'|0x80),
|
||||
' ','(','O',')',' ', '=','O','H','4',(char)('W'|0x80),
|
||||
'(','O','F',')',' ', '=','A','H',(char)('V'|0x80),
|
||||
' ','(','O','H',')',' ', '=','O','W',(char)('5'|0x80),
|
||||
'(','O','R','O','U','G','H',')', '=','E','R','4','O',(char)('W'|0x80),
|
||||
'#',':','(','O','R',')',' ', '=','E',(char)('R'|0x80),
|
||||
'#',':','(','O','R','S',')',' ', '=','E','R',(char)('Z'|0x80),
|
||||
'(','O','R',')', '=','A','O',(char)('R'|0x80),
|
||||
' ','(','O','N','E',')', '=','W','A','H',(char)('N'|0x80),
|
||||
'#','(','O','N','E',')',' ', '=','W','A','H',(char)('N'|0x80),
|
||||
'(','O','W',')', '=','O',(char)('W'|0x80),
|
||||
' ','(','O','V','E','R',')', '=','O','W','5','V','E',(char)('R'|0x80),
|
||||
'P','R','(','O',')','V', '=','U','W',(char)('4'|0x80),
|
||||
'(','O','V',')', '=','A','H','4',(char)('V'|0x80),
|
||||
'(','O',')','^','%', '=','O','W',(char)('5'|0x80),
|
||||
'(','O',')','^','E','N', '=','O',(char)('W'|0x80),
|
||||
'(','O',')','^','I','#', '=','O','W',(char)('5'|0x80),
|
||||
'(','O','L',')','D', '=','O','W','4',(char)('L'|0x80),
|
||||
'(','O','U','G','H','T',')', '=','A','O','5',(char)('T'|0x80),
|
||||
'(','O','U','G','H',')', '=','A','H','5',(char)('F'|0x80),
|
||||
' ','(','O','U',')', '=','A',(char)('W'|0x80),
|
||||
'H','(','O','U',')','S','#', '=','A','W',(char)('4'|0x80),
|
||||
'(','O','U','S',')', '=','A','X',(char)('S'|0x80),
|
||||
'(','O','U','R',')', '=','O','H',(char)('R'|0x80),
|
||||
'(','O','U','L','D',')', '=','U','H','5',(char)('D'|0x80),
|
||||
'(','O','U',')','^','L', '=','A','H',(char)('5'|0x80),
|
||||
'(','O','U','P',')', '=','U','W','5',(char)('P'|0x80),
|
||||
'(','O','U',')', '=','A',(char)('W'|0x80),
|
||||
'(','O','Y',')', '=','O',(char)('Y'|0x80),
|
||||
'(','O','I','N','G',')', '=','O','W','4','I','H','N',(char)('X'|0x80),
|
||||
'(','O','I',')', '=','O','Y',(char)('5'|0x80),
|
||||
'(','O','O','R',')', '=','O','H','5',(char)('R'|0x80),
|
||||
'(','O','O','K',')', '=','U','H','5',(char)('K'|0x80),
|
||||
'F','(','O','O','D',')', '=','U','W','5',(char)('D'|0x80),
|
||||
'L','(','O','O','D',')', '=','A','H','5',(char)('D'|0x80),
|
||||
'M','(','O','O','D',')', '=','U','W','5',(char)('D'|0x80),
|
||||
'(','O','O','D',')', '=','U','H','5',(char)('D'|0x80),
|
||||
'F','(','O','O','T',')', '=','U','H','5',(char)('T'|0x80),
|
||||
'(','O','O',')', '=','U','W',(char)('5'|0x80),
|
||||
'(','O','\'',')', '=','O',(char)('H'|0x80),
|
||||
'(','O',')','E', '=','O',(char)('W'|0x80),
|
||||
'(','O',')',' ', '=','O',(char)('W'|0x80),
|
||||
'(','O','A',')', '=','O','W',(char)('4'|0x80),
|
||||
' ','(','O','N','L','Y',')', '=','O','W','4','N','L','I',(char)('Y'|0x80),
|
||||
' ','(','O','N','C','E',')', '=','W','A','H','4','N',(char)('S'|0x80),
|
||||
'(','O','N','\'','T',')', '=','O','W','4','N',(char)('T'|0x80),
|
||||
'C','(','O',')','N', '=','A',(char)('A'|0x80),
|
||||
'(','O',')','N','G', '=','A',(char)('O'|0x80),
|
||||
' ',':','^','(','O',')','N', '=','A',(char)('H'|0x80),
|
||||
'I','(','O','N',')', '=','U',(char)('N'|0x80),
|
||||
'#',':','(','O','N',')', '=','U',(char)('N'|0x80),
|
||||
'#','^','(','O','N',')', '=','U',(char)('N'|0x80),
|
||||
'(','O',')','S','T', '=','O',(char)('W'|0x80),
|
||||
'(','O','F',')','^', '=','A','O','4',(char)('F'|0x80),
|
||||
'(','O','T','H','E','R',')', '=','A','H','5','D','H','E',(char)('R'|0x80),
|
||||
'R','(','O',')','B', '=','R','A',(char)('A'|0x80),
|
||||
'^','R','(','O',')',':','#', '=','O','W',(char)('5'|0x80),
|
||||
'(','O','S','S',')',' ', '=','A','O','5',(char)('S'|0x80),
|
||||
'#',':','^','(','O','M',')', '=','A','H',(char)('M'|0x80),
|
||||
'(','O',')', '=','A',(char)('A'|0x80),
|
||||
|
||||
']',(char)('P'|0x80),
|
||||
' ','(','P',')',' ', '=','P','I','Y',(char)('4'|0x80),
|
||||
'(','P','H',')', '=',(char)('F'|0x80),
|
||||
'(','P','E','O','P','L',')', '=','P','I','Y','5','P','U',(char)('L'|0x80),
|
||||
'(','P','O','W',')', '=','P','A','W',(char)('4'|0x80),
|
||||
'(','P','U','T',')',' ', '=','P','U','H',(char)('T'|0x80),
|
||||
'(','P',')','P',(char)('='|0x80),
|
||||
'(','P',')','S',(char)('='|0x80),
|
||||
'(','P',')','N',(char)('='|0x80),
|
||||
'(','P','R','O','F','.',')', '=','P','R','O','H','F','E','H','4','S','E',(char)('R'|0x80),
|
||||
'(','P',')', '=',(char)('P'|0x80),
|
||||
|
||||
']',(char)('Q'|0x80),
|
||||
' ','(','Q',')',' ', '=','K','Y','U','W',(char)('4'|0x80),
|
||||
'(','Q','U','A','R',')', '=','K','W','O','H','5',(char)('R'|0x80),
|
||||
'(','Q','U',')', '=','K',(char)('W'|0x80),
|
||||
'(','Q',')', '=',(char)('K'|0x80),
|
||||
']',(char)('R'|0x80),
|
||||
' ','(','R',')',' ', '=','A','A','5',(char)('R'|0x80),
|
||||
' ','(','R','E',')','^','#', '=','R','I',(char)('Y'|0x80),
|
||||
'(','R',')','R',(char)('='|0x80),
|
||||
'(','R',')', '=',(char)('R'|0x80),
|
||||
|
||||
']',(char)('S'|0x80),
|
||||
' ','(','S',')',' ', '=','E','H','4',(char)('S'|0x80),
|
||||
'(','S','H',')', '=','S',(char)('H'|0x80),
|
||||
'#','(','S','I','O','N',')', '=','Z','H','U',(char)('N'|0x80),
|
||||
'(','S','O','M','E',')', '=','S','A','H',(char)('M'|0x80),
|
||||
'#','(','S','U','R',')','#', '=','Z','H','E',(char)('R'|0x80),
|
||||
'(','S','U','R',')','#', '=','S','H','E',(char)('R'|0x80),
|
||||
'#','(','S','U',')','#', '=','Z','H','U',(char)('W'|0x80),
|
||||
'#','(','S','S','U',')','#', '=','S','H','U',(char)('W'|0x80),
|
||||
'#','(','S','E','D',')', '=','Z',(char)('D'|0x80),
|
||||
'#','(','S',')','#', '=',(char)('Z'|0x80),
|
||||
'(','S','A','I','D',')', '=','S','E','H',(char)('D'|0x80),
|
||||
'^','(','S','I','O','N',')', '=','S','H','U',(char)('N'|0x80),
|
||||
'(','S',')','S',(char)('='|0x80),
|
||||
'.','(','S',')',' ', '=',(char)('Z'|0x80),
|
||||
'#',':','.','E','(','S',')',' ', '=',(char)('Z'|0x80),
|
||||
'#',':','^','#','(','S',')',' ', '=',(char)('S'|0x80),
|
||||
'U','(','S',')',' ', '=',(char)('S'|0x80),
|
||||
' ',':','#','(','S',')',' ', '=',(char)('Z'|0x80),
|
||||
'#','#','(','S',')',' ', '=',(char)('Z'|0x80),
|
||||
' ','(','S','C','H',')', '=','S',(char)('K'|0x80),
|
||||
'(','S',')','C','+',(char)('='|0x80),
|
||||
'#','(','S','M',')', '=','Z','U',(char)('M'|0x80),
|
||||
'#','(','S','N',')','\'', '=','Z','U',(char)('M'|0x80),
|
||||
'(','S','T','L','E',')', '=','S','U',(char)('L'|0x80),
|
||||
'(','S',')', '=',(char)('S'|0x80),
|
||||
|
||||
']',(char)('T'|0x80),
|
||||
' ','(','T',')',' ', '=','T','I','Y',(char)('4'|0x80),
|
||||
' ','(','T','H','E',')',' ','#', '=','D','H','I',(char)('Y'|0x80),
|
||||
' ','(','T','H','E',')',' ', '=','D','H','A',(char)('X'|0x80),
|
||||
'(','T','O',')',' ', '=','T','U',(char)('X'|0x80),
|
||||
' ','(','T','H','A','T',')', '=','D','H','A','E',(char)('T'|0x80),
|
||||
' ','(','T','H','I','S',')',' ', '=','D','H','I','H',(char)('S'|0x80),
|
||||
' ','(','T','H','E','Y',')', '=','D','H','E',(char)('Y'|0x80),
|
||||
' ','(','T','H','E','R','E',')', '=','D','H','E','H',(char)('R'|0x80),
|
||||
'(','T','H','E','R',')', '=','D','H','E',(char)('R'|0x80),
|
||||
'(','T','H','E','I','R',')', '=','D','H','E','H',(char)('R'|0x80),
|
||||
' ','(','T','H','A','N',')',' ', '=','D','H','A','E',(char)('N'|0x80),
|
||||
' ','(','T','H','E','M',')',' ', '=','D','H','A','E',(char)('N'|0x80),
|
||||
'(','T','H','E','S','E',')',' ', '=','D','H','I','Y',(char)('Z'|0x80),
|
||||
' ','(','T','H','E','N',')', '=','D','H','E','H',(char)('N'|0x80),
|
||||
'(','T','H','R','O','U','G','H',')', '=','T','H','R','U','W',(char)('4'|0x80),
|
||||
'(','T','H','O','S','E',')', '=','D','H','O','H',(char)('Z'|0x80),
|
||||
'(','T','H','O','U','G','H',')',' ', '=','D','H','O',(char)('W'|0x80),
|
||||
'(','T','O','D','A','Y',')', '=','T','U','X','D','E',(char)('Y'|0x80),
|
||||
'(','T','O','M','O',')','R','R','O','W','=','T','U','M','A','A',(char)('5'|0x80),
|
||||
'(','T','O',')','T','A','L', '=','T','O','W',(char)('5'|0x80),
|
||||
' ','(','T','H','U','S',')', '=','D','H','A','H','4',(char)('S'|0x80),
|
||||
'(','T','H',')', '=','T',(char)('H'|0x80),
|
||||
'#',':','(','T','E','D',')', '=','T','I','X',(char)('D'|0x80),
|
||||
'S','(','T','I',')','#','N', '=','C',(char)('H'|0x80),
|
||||
'(','T','I',')','O', '=','S',(char)('H'|0x80),
|
||||
'(','T','I',')','A', '=','S',(char)('H'|0x80),
|
||||
'(','T','I','E','N',')', '=','S','H','U',(char)('N'|0x80),
|
||||
'(','T','U','R',')','#', '=','C','H','E',(char)('R'|0x80),
|
||||
'(','T','U',')','A', '=','C','H','U',(char)('W'|0x80),
|
||||
' ','(','T','W','O',')', '=','T','U',(char)('W'|0x80),
|
||||
'&','(','T',')','E','N',' ',(char)('='|0x80),
|
||||
'(','T',')', '=',(char)('T'|0x80),
|
||||
|
||||
']',(char)('U'|0x80),
|
||||
' ','(','U',')',' ', '=','Y','U','W',(char)('4'|0x80),
|
||||
' ','(','U','N',')','I', '=','Y','U','W',(char)('N'|0x80),
|
||||
' ','(','U','N',')', '=','A','H',(char)('N'|0x80),
|
||||
' ','(','U','P','O','N',')', '=','A','X','P','A','O',(char)('N'|0x80),
|
||||
'@','(','U','R',')','#', '=','U','H','4',(char)('R'|0x80),
|
||||
'(','U','R',')','#', '=','Y','U','H','4',(char)('R'|0x80),
|
||||
'(','U','R',')', '=','E',(char)('R'|0x80),
|
||||
'(','U',')','^',' ', '=','A',(char)('H'|0x80),
|
||||
'(','U',')','^','^', '=','A','H',(char)('5'|0x80),
|
||||
'(','U','Y',')', '=','A','Y',(char)('5'|0x80),
|
||||
' ','G','(','U',')','#',(char)('='|0x80),
|
||||
'G','(','U',')','%',(char)('='|0x80),
|
||||
'G','(','U',')','#', '=',(char)('W'|0x80),
|
||||
'#','N','(','U',')', '=','Y','U',(char)('W'|0x80),
|
||||
'@','(','U',')', '=','U',(char)('W'|0x80),
|
||||
'(','U',')', '=','Y','U',(char)('W'|0x80),
|
||||
|
||||
']',(char)('V'|0x80),
|
||||
' ','(','V',')',' ', '=','V','I','Y',(char)('4'|0x80),
|
||||
'(','V','I','E','W',')', '=','V','Y','U','W',(char)('5'|0x80),
|
||||
'(','V',')', '=',(char)('V'|0x80),
|
||||
|
||||
']',(char)('W'|0x80),
|
||||
' ','(','W',')',' ', '=','D','A','H','4','B','U','L','Y','U',(char)('W'|0x80),
|
||||
' ','(','W','E','R','E',')', '=','W','E',(char)('R'|0x80),
|
||||
'(','W','A',')','S','H', '=','W','A',(char)('A'|0x80),
|
||||
'(','W','A',')','S','T', '=','W','E',(char)('Y'|0x80),
|
||||
'(','W','A',')','S', '=','W','A',(char)('H'|0x80),
|
||||
'(','W','A',')','T', '=','W','A',(char)('A'|0x80),
|
||||
'(','W','H','E','R','E',')', '=','W','H','E','H',(char)('R'|0x80),
|
||||
'(','W','H','A','T',')', '=','W','H','A','H',(char)('T'|0x80),
|
||||
'(','W','H','O','L',')', '=','/','H','O','W',(char)('L'|0x80),
|
||||
'(','W','H','O',')', '=','/','H','U',(char)('W'|0x80),
|
||||
'(','W','H',')', '=','W',(char)('H'|0x80),
|
||||
'(','W','A','R',')','#', '=','W','E','H',(char)('R'|0x80),
|
||||
'(','W','A','R',')', '=','W','A','O',(char)('R'|0x80),
|
||||
'(','W','O','R',')','^', '=','W','E',(char)('R'|0x80),
|
||||
'(','W','R',')', '=',(char)('R'|0x80),
|
||||
'(','W','O','M',')','A', '=','W','U','H',(char)('M'|0x80),
|
||||
'(','W','O','M',')','E', '=','W','I','H',(char)('M'|0x80),
|
||||
'(','W','E','A',')','R', '=','W','E',(char)('H'|0x80),
|
||||
'(','W','A','N','T',')', '=','W','A','A','5','N',(char)('T'|0x80),
|
||||
'A','N','S','(','W','E','R',')', '=','E',(char)('R'|0x80),
|
||||
'(','W',')', '=',(char)('W'|0x80),
|
||||
|
||||
']',(char)('X'|0x80),
|
||||
' ','(','X',')',' ', '=','E','H','4','K',(char)('R'|0x80),
|
||||
' ','(','X',')', '=',(char)('Z'|0x80),
|
||||
'(','X',')', '=','K',(char)('S'|0x80),
|
||||
|
||||
']',(char)('Y'|0x80),
|
||||
' ','(','Y',')',' ', '=','W','A','Y',(char)('4'|0x80),
|
||||
'(','Y','O','U','N','G',')', '=','Y','A','H','N',(char)('X'|0x80),
|
||||
' ','(','Y','O','U','R',')', '=','Y','O','H',(char)('R'|0x80),
|
||||
' ','(','Y','O','U',')', '=','Y','U',(char)('W'|0x80),
|
||||
' ','(','Y','E','S',')', '=','Y','E','H',(char)('S'|0x80),
|
||||
' ','(','Y',')', '=',(char)('Y'|0x80),
|
||||
'F','(','Y',')', '=','A',(char)('Y'|0x80),
|
||||
'P','S','(','Y','C','H',')', '=','A','Y',(char)('K'|0x80),
|
||||
'#',':','^','(','Y',')', '=','I',(char)('Y'|0x80),
|
||||
'#',':','^','(','Y',')','I', '=','I',(char)('Y'|0x80),
|
||||
' ',':','(','Y',')',' ', '=','A',(char)('Y'|0x80),
|
||||
' ',':','(','Y',')','#', '=','A',(char)('Y'|0x80),
|
||||
' ',':','(','Y',')','^','+',':','#', '=','I',(char)('H'|0x80),
|
||||
' ',':','(','Y',')','^','#', '=','A',(char)('Y'|0x80),
|
||||
'(','Y',')', '=','I',(char)('H'|0x80),
|
||||
|
||||
']',(char)('Z'|0x80),
|
||||
' ','(','Z',')',' ', '=','Z','I','Y',(char)('4'|0x80),
|
||||
'(','Z',')', '=',(char)('Z'|0x80),
|
||||
(char)('j'|0x80)
|
||||
};
|
||||
|
||||
static char[] rules2 =
|
||||
{
|
||||
'(','A',')', (char)('='|0x80),
|
||||
'(','!',')', '=',(char)('.'|0x80),
|
||||
'(','"',')',' ', '=','-','A','H','5','N','K','W','O','W','T',(char)('-'|0x80),
|
||||
'(','"',')', '=','K','W','O','W','4','T',(char)('-'|0x80),
|
||||
'(','#',')', '=',' ','N','A','H','4','M','B','E',(char)('R'|0x80),
|
||||
'(','$',')', '=',' ','D','A','A','4','L','E',(char)('R'|0x80),
|
||||
'(','%',')', '=',' ','P','E','R','S','E','H','4','N',(char)('T'|0x80),
|
||||
'(','&',')', '=',' ','A','E','N',(char)('D'|0x80),
|
||||
'(','\'',')', (char)('='|0x80),
|
||||
'(','*',')', '=',' ','A','E','4','S','T','E','R','I','H','S',(char)('K'|0x80),
|
||||
'(','+',')', '=',' ','P','L','A','H','4',(char)('S'|0x80),
|
||||
'(',',',')', '=',(char)(','|0x80),
|
||||
' ','(','-',')',' ', '=',(char)('-'|0x80),
|
||||
'(','-',')', (char)('='|0x80),
|
||||
'(','.',')', '=',' ','P','O','Y','N',(char)('T'|0x80),
|
||||
'(','/',')', '=',' ','S','L','A','E','4','S',(char)('H'|0x80),
|
||||
'(','0',')', '=',' ','Z','I','Y','4','R','O',(char)('W'|0x80),
|
||||
' ','(','1','S','T',')', '=','F','E','R','4','S',(char)('T'|0x80),
|
||||
' ','(','1','0','T','H',')', '=','T','E','H','4','N','T',(char)('H'|0x80),
|
||||
'(','1',')', '=',' ','W','A','H','4',(char)('N'|0x80),
|
||||
' ','(','2','N','D',')', '=','S','E','H','4','K','U','N',(char)('D'|0x80),
|
||||
'(','2',')', '=',' ','T','U','W',(char)('4'|0x80),
|
||||
' ','(','3','R','D',')', '=','T','H','E','R','4',(char)('D'|0x80),
|
||||
'(','3',')', '=',' ','T','H','R','I','Y',(char)('4'|0x80),
|
||||
'(','4',')', '=',' ','F','O','H','4',(char)('R'|0x80),
|
||||
' ','(','5','T','H',')', '=','F','I','H','4','F','T',(char)('H'|0x80),
|
||||
'(','5',')', '=',' ','F','A','Y','4',(char)('V'|0x80),
|
||||
' ','(','6','4',')',' ', '=','S','I','H','4','K','S','T','I','Y',' ','F','O','H',(char)('R'|0x80),
|
||||
'(','6',')', '=',' ','S','I','H','4','K',(char)('S'|0x80),
|
||||
'(','7',')', '=',' ','S','E','H','4','V','U',(char)('N'|0x80),
|
||||
' ','(','8','T','H',')', '=','E','Y','4','T',(char)('H'|0x80),
|
||||
'(','8',')', '=',' ','E','Y','4',(char)('T'|0x80),
|
||||
'(','9',')', '=',' ','N','A','Y','4',(char)('N'|0x80),
|
||||
'(',':',')', '=',(char)('.'|0x80),
|
||||
'(',';',')', '=',(char)('.'|0x80),
|
||||
'(','<',')', '=',' ','L','E','H','4','S',' ','D','H','A','E',(char)('N'|0x80),
|
||||
'(','=',')', '=',' ','I','Y','4','K','W','U','L',(char)('Z'|0x80),
|
||||
'(','>',')', '=',' ','G','R','E','Y','4','T','E','R',' ','D','H','A','E',(char)('N'|0x80),
|
||||
'(','?',')', '=',(char)('?'|0x80),
|
||||
'(','@',')', '=',' ','A','E','6',(char)('T'|0x80),
|
||||
'(','^',')', '=',' ','K','A','E','4','R','I','X',(char)('T'|0x80),
|
||||
']',(char)('A'|0x80)
|
||||
};
|
||||
|
||||
//26 items. From 'A' to 'Z'
|
||||
// positions for mem62 and mem63 for each character
|
||||
static byte[] tab37489 =
|
||||
{
|
||||
0, 149, 247, 162, 57, 197, 6, 126,
|
||||
199, 38, 55, 78, 145, 241, 85, 161,
|
||||
254, 36, 69, 45, 167, 54, 83, 46,
|
||||
71, 218
|
||||
};
|
||||
|
||||
static byte[] tab37515 =
|
||||
{
|
||||
125, 126, 126, 127, 128, 129, 130, 130,
|
||||
130, 132, 132, 132, 132, 132, 133, 135,
|
||||
135, 136, 136, 137, 138, 139, 139, 140,
|
||||
140, 140
|
||||
};
|
||||
|
||||
static byte A, X;
|
||||
|
||||
static byte[] inputtemp = new byte[256]; // secure copy of input tab36096
|
||||
|
||||
/* Retrieve flags for character at mem59-1 */
|
||||
static byte Code37055(byte npos, byte mask)
|
||||
{
|
||||
X = npos;
|
||||
return (byte)(tab36376[inputtemp[X]] & mask);
|
||||
}
|
||||
|
||||
static uint match(string str)
|
||||
{
|
||||
int pos = 0;
|
||||
while (pos < str.Length)
|
||||
{
|
||||
char ch = str[pos];
|
||||
A = inputtemp[X++];
|
||||
if (A != ch) return 0;
|
||||
++pos;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static byte GetRuleByte(ushort mem62, byte Y)
|
||||
{
|
||||
uint address = mem62;
|
||||
if (mem62 >= 37541)
|
||||
{
|
||||
address -= 37541;
|
||||
return (byte)rules2[address + Y];
|
||||
}
|
||||
address -= 32000;
|
||||
return (byte)rules[address + Y];
|
||||
}
|
||||
|
||||
static int handle_ch2(byte ch, byte mem)
|
||||
{
|
||||
byte tmp;
|
||||
X = mem;
|
||||
tmp = tab36376[inputtemp[mem]];
|
||||
if (ch == ' ')
|
||||
{
|
||||
if ((tmp & 128) != 0) return 1;
|
||||
}
|
||||
else if (ch == '#')
|
||||
{
|
||||
if ((tmp & 64) == 0) return 1;
|
||||
}
|
||||
else if (ch == '.')
|
||||
{
|
||||
if ((tmp & 8) == 0) return 1;
|
||||
}
|
||||
else if (ch == '^')
|
||||
{
|
||||
if ((tmp & 32) == 0) return 1;
|
||||
}
|
||||
else return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int handle_ch(byte ch, byte mem)
|
||||
{
|
||||
byte tmp;
|
||||
X = mem;
|
||||
tmp = tab36376[inputtemp[X]];
|
||||
if (ch == ' ')
|
||||
{
|
||||
if ((tmp & 128) != 0) return 1;
|
||||
}
|
||||
else if (ch == '#')
|
||||
{
|
||||
if ((tmp & 64) == 0) return 1;
|
||||
}
|
||||
else if (ch == '.')
|
||||
{
|
||||
if ((tmp & 8) == 0) return 1;
|
||||
}
|
||||
else if (ch == '&')
|
||||
{
|
||||
if ((tmp & 16) == 0)
|
||||
{
|
||||
if (inputtemp[X] != 72) return 1;
|
||||
++X;
|
||||
}
|
||||
}
|
||||
else if (ch == '^')
|
||||
{
|
||||
if ((tmp & 32) == 0) return 1;
|
||||
}
|
||||
else if (ch == '+')
|
||||
{
|
||||
X = mem;
|
||||
ch = inputtemp[X];
|
||||
if ((ch != 69) && (ch != 73) && (ch != 89)) return 1;
|
||||
}
|
||||
else return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int TextToPhonemes(byte[] input)
|
||||
{
|
||||
byte mem56; //output position for phonemes
|
||||
byte mem57;
|
||||
byte mem58;
|
||||
byte mem59;
|
||||
byte mem60;
|
||||
byte mem61;
|
||||
ushort mem62; // memory position of current rule
|
||||
|
||||
byte mem64; // position of '=' or current character
|
||||
byte mem65; // position of ')'
|
||||
byte mem66; // position of '('
|
||||
|
||||
byte Y;
|
||||
|
||||
int r;
|
||||
|
||||
inputtemp[0] = (byte)' ';
|
||||
|
||||
// secure copy of input
|
||||
// because input will be overwritten by phonemes
|
||||
X = 0;
|
||||
do
|
||||
{
|
||||
A = (byte)(input[X] & 127);
|
||||
if (A >= 112) A = (byte)(A & 95);
|
||||
else if (A >= 96) A = (byte)(A & 79);
|
||||
inputtemp[++X] = A;
|
||||
} while (X < 255);
|
||||
inputtemp[255] = 27;
|
||||
mem56 = mem61 = 255;
|
||||
|
||||
pos36554:
|
||||
while (true)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
X = ++mem61;
|
||||
mem64 = inputtemp[X];
|
||||
if (mem64 == '[')
|
||||
{
|
||||
X = ++mem56;
|
||||
input[X] = 155;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mem64 != '.') break;
|
||||
X++;
|
||||
A = (byte)(tab36376[inputtemp[X]] & 1);
|
||||
if (A != 0) break;
|
||||
mem56++;
|
||||
X = mem56;
|
||||
A = (byte)'.';
|
||||
input[X] = (byte)'.';
|
||||
}
|
||||
mem57 = tab36376[mem64];
|
||||
if ((mem57 & 2) != 0)
|
||||
{
|
||||
mem62 = 37541;
|
||||
goto pos36700;
|
||||
}
|
||||
|
||||
if (mem57 != 0) break;
|
||||
inputtemp[X] = (byte)' ';
|
||||
X = ++mem56;
|
||||
if (X > 120)
|
||||
{
|
||||
input[X] = 155;
|
||||
return 1;
|
||||
}
|
||||
input[X] = 32;
|
||||
}
|
||||
|
||||
if ((mem57 & 128) == 0) return 0;
|
||||
|
||||
// go to the right rules for this character.
|
||||
X = (byte)(mem64 - 'A');
|
||||
mem62 = (ushort)(tab37489[X] | (tab37515[X] << 8));
|
||||
|
||||
pos36700:
|
||||
// find next rule
|
||||
while ((GetRuleByte(++mem62, 0) & 128) == 0) ;
|
||||
Y = 0;
|
||||
while (GetRuleByte(mem62, ++Y) != '(') ;
|
||||
mem66 = Y;
|
||||
while (GetRuleByte(mem62, ++Y) != ')') ;
|
||||
mem65 = Y;
|
||||
while ((GetRuleByte(mem62, ++Y) & 127) != '=') ;
|
||||
mem64 = Y;
|
||||
|
||||
|
||||
mem60 = X = mem61;
|
||||
// compare the string within the bracket
|
||||
Y = (byte)(mem66 + 1);
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (GetRuleByte(mem62, Y) != inputtemp[X]) goto pos36700;
|
||||
if (++Y == mem65) break;
|
||||
mem60 = ++X;
|
||||
}
|
||||
|
||||
// the string in the bracket is correct
|
||||
|
||||
mem59 = mem61;
|
||||
|
||||
while (true)
|
||||
{
|
||||
byte ch;
|
||||
while (true)
|
||||
{
|
||||
mem66--;
|
||||
mem57 = GetRuleByte(mem62, mem66);
|
||||
if ((mem57 & 128) != 0)
|
||||
{
|
||||
mem58 = mem60;
|
||||
goto pos37184;
|
||||
}
|
||||
X = (byte)(mem57 & 127);
|
||||
if ((tab36376[X] & 128) == 0) break;
|
||||
if (inputtemp[mem59 - 1] != mem57) goto pos36700;
|
||||
--mem59;
|
||||
}
|
||||
|
||||
ch = mem57;
|
||||
|
||||
r = handle_ch2(ch, (byte)(mem59 - 1));
|
||||
if (r == -1)
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
case (byte)'&':
|
||||
if (Code37055((byte)(mem59 - 1), 16) == 0)
|
||||
{
|
||||
if (inputtemp[X] != 'H') r = 1;
|
||||
else
|
||||
{
|
||||
A = inputtemp[--X];
|
||||
if ((A != 'C') && (A != 'S')) r = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case (byte)'@':
|
||||
if (Code37055((byte)(mem59 - 1), 4) == 0)
|
||||
{
|
||||
A = inputtemp[X];
|
||||
if (A != 72) r = 1;
|
||||
if ((A != 84) && (A != 67) && (A != 83)) r = 1;
|
||||
}
|
||||
break;
|
||||
case (byte)'+':
|
||||
X = mem59;
|
||||
A = inputtemp[--X];
|
||||
if ((A != 'E') && (A != 'I') && (A != 'Y')) r = 1;
|
||||
break;
|
||||
case (byte)':':
|
||||
while (Code37055((byte)(mem59 - 1), 32) != 0) --mem59;
|
||||
continue;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (r == 1) goto pos36700;
|
||||
|
||||
mem59 = X;
|
||||
}
|
||||
|
||||
pos37184:
|
||||
do
|
||||
{
|
||||
bool first = false;
|
||||
|
||||
if (first)
|
||||
{
|
||||
X = (byte)(mem58 + 1);
|
||||
if (inputtemp[X] == 'E')
|
||||
{
|
||||
if ((tab36376[inputtemp[X + 1]] & 128) != 0)
|
||||
{
|
||||
A = inputtemp[++X];
|
||||
if (A == 'L')
|
||||
{
|
||||
if (inputtemp[++X] != 'Y') goto pos36700;
|
||||
}
|
||||
else if ((A != 'R') && (A != 'S') && (A != 'D') && match("FUL") == 0) goto pos36700;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (match("ING") == 0) goto pos36700;
|
||||
mem58 = X;
|
||||
}
|
||||
}
|
||||
|
||||
first = true;
|
||||
|
||||
r = 0;
|
||||
do
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
Y = (byte)(mem65 + 1);
|
||||
if (Y == mem64)
|
||||
{
|
||||
mem61 = mem60;
|
||||
|
||||
while (true)
|
||||
{
|
||||
mem57 = A = GetRuleByte(mem62, Y);
|
||||
A = (byte)(A & 127);
|
||||
if (A != '=') input[++mem56] = A;
|
||||
if ((mem57 & 128) != 0) goto pos36554;
|
||||
Y++;
|
||||
}
|
||||
}
|
||||
mem65 = Y;
|
||||
mem57 = GetRuleByte(mem62, Y);
|
||||
if ((tab36376[mem57] & 128) == 0) break;
|
||||
if (inputtemp[mem58 + 1] != mem57)
|
||||
{
|
||||
r = 1;
|
||||
break;
|
||||
}
|
||||
++mem58;
|
||||
}
|
||||
|
||||
if (r == 0)
|
||||
{
|
||||
A = mem57;
|
||||
if (A == '@')
|
||||
{
|
||||
if (Code37055((byte)(mem58 + 1), 4) == 0)
|
||||
{
|
||||
A = inputtemp[X];
|
||||
if ((A != 82) && (A != 84) &&
|
||||
(A != 67) && (A != 83)) r = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = -2;
|
||||
}
|
||||
}
|
||||
else if (A == ':')
|
||||
{
|
||||
while (Code37055((byte)(mem58 + 1), 32) != 0) mem58 = X;
|
||||
r = -2;
|
||||
}
|
||||
else r = handle_ch(A, (byte)(mem58 + 1));
|
||||
}
|
||||
|
||||
if (r == 1) goto pos36700;
|
||||
if (r == -2)
|
||||
{
|
||||
r = 0;
|
||||
continue;
|
||||
}
|
||||
if (r == 0) mem58 = X;
|
||||
} while (r == 0);
|
||||
} while (A == '%');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue