Skip to content

Commit eae031d

Browse files
author
Kurt Dekker
committed
UnitySAM: Test1 harness improvements after studying main.c
1 parent f0ae8ab commit eae031d

File tree

4 files changed

+49
-12
lines changed

4 files changed

+49
-12
lines changed

UnitySAM/Assets/SAMCSourceCode/src/Modernity.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,20 @@ static int[] IntArray(string s)
1919

2020
public static string TextToPhonemes(string s)
2121
{
22-
TextToPhonemes(IntArray( s));
22+
var ia = IntArray( s);
2323

24-
var bytes = new byte[ inputtemp.Length];
24+
bool success = TextToPhonemes(ia);
25+
26+
var what = ia;
27+
28+
what = inputtemp;
29+
30+
var bytes = new byte[ what.Length];
2531
for (int i = 0; i < 256; i++)
2632
{
27-
if (inputtemp[i] != 0)
33+
if (what[i] != 0)
2834
{
29-
bytes[i] = (byte)inputtemp[i];
35+
bytes[i] = (byte)what[i];
3036
}
3137
}
3238

UnitySAM/Assets/SAMCSourceCode/src/SamDebug.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,27 @@ public static partial class UnitySAM
44
{
55
static void printf(string s)
66
{
7-
Debug.Log("Print:" + s);
7+
Debug.Log("Print:'" + s + "'");
8+
}
9+
10+
static void printf(int[] ia)
11+
{
12+
byte[] bytes = new byte[ia.Length];
13+
for (int i = 0; i < ia.Length; i++)
14+
{
15+
if (ia[i] == 0)
16+
{
17+
var copy = new byte[i];
18+
System.Array.Copy( bytes, copy, i);
19+
bytes = copy;
20+
break;
21+
}
22+
bytes[i] = (byte)ia[i];
23+
}
24+
25+
string s = System.Text.Encoding.UTF8.GetString(bytes);
26+
27+
printf( s);
828
}
929

1030
static void PrintRule(int i)

UnitySAM/Assets/SAMCSourceCode/src/reciter_c.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static int GetRuleByte(int mem62, int Y)
3838
return rules[address + Y];
3939
}
4040

41-
static int TextToPhonemes( int[] input) // Code36484
41+
static bool TextToPhonemes( int[] input) // Code36484
4242
{
4343
//unsigned char *tab39445 = &mem[39445]; //input and output
4444
//unsigned char mem29;
@@ -75,6 +75,7 @@ static int TextToPhonemes( int[] input) // Code36484
7575
Y++;
7676
} while (Y != 255);
7777

78+
printf( inputtemp);
7879

7980
X = 255;
8081
inputtemp[X] = 27;
@@ -104,7 +105,7 @@ static int TextToPhonemes( int[] input) // Code36484
104105
input[X] = 155;
105106
//goto pos36542;
106107
// Code39771(); //Code39777();
107-
return 1;
108+
return true;
108109
}
109110

110111
//pos36579:
@@ -136,7 +137,7 @@ static int TextToPhonemes( int[] input) // Code36484
136137
if (A != 0) goto pos36677;
137138
A = 32;
138139

139-
if (X >= inputtemp.Length) return 0;
140+
if (X >= inputtemp.Length) return true;
140141

141142
inputtemp[X] = ' ';
142143
mem56++;
@@ -155,7 +156,7 @@ static int TextToPhonemes( int[] input) // Code36484
155156
mem36653 = A;
156157
// mem29 = A; // not used
157158
// Code36538(); das ist eigentlich
158-
return 1;
159+
return true;
159160
//Code39771();
160161
//go on if there is more input ???
161162

@@ -167,7 +168,7 @@ static int TextToPhonemes( int[] input) // Code36484
167168
if (A == 0)
168169
{
169170
//36683: BRK
170-
return 0;
171+
return false;
171172
}
172173

173174
// go to the right rules for this character.
@@ -272,7 +273,7 @@ static int TextToPhonemes( int[] input) // Code36484
272273
if (A == ':') goto pos37040;
273274
// Code42041(); //Error
274275
//36894: BRK
275-
return 0;
276+
return false;
276277

277278
// --------------
278279

@@ -446,7 +447,7 @@ static int TextToPhonemes( int[] input) // Code36484
446447
//pos37291:
447448
// Code42041(); //Error
448449
//37294: BRK
449-
return 0;
450+
return false;
450451

451452
// --------------
452453
pos37295:

UnitySAM/Assets/Test1/Test1.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ void Start ()
2929

3030
string s = "HELLO";
3131

32+
bool phonetic = false;
33+
if (phonetic)
34+
{
35+
s = s + "\0x9b";
36+
}
37+
else
38+
{
39+
s = s + "[";
40+
}
41+
3242
Out(s);
3343

3444
var x = UnitySAM.TextToPhonemes(s);

0 commit comments

Comments
 (0)