Skip to content

Commit 284de9b

Browse files
author
ByteSizedFox
committed
add more keys to GBA port for phonemes and enable phonemes by default
1 parent d2917fe commit 284de9b

1 file changed

Lines changed: 23 additions & 14 deletions

File tree

gba/main.c

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ int input_len = 0;
2020
int cursor_x = 0;
2121
int cursor_y = 0;
2222

23-
const char keyboard[4][13] = {
24-
"abcdefghijkl",
25-
"mnopqrstuvwx",
26-
"yz 1234567890",
27-
".,!?-'\"\x7F" // \x7F is DEL, used as backspace marker
23+
const char keyboard[4][16] = {
24+
"abcdefghijklmno",
25+
"pqrstuvwxyz ",
26+
"1234567890.,!? ",
27+
"-'\":<>()[]\x7F " // \x7F is DEL, used as backspace marker
2828
};
2929

3030
void draw_screen() {
@@ -48,11 +48,11 @@ void draw_screen() {
4848
tte_write(input_text);
4949

5050
// Keyboard - build each row with cursor highlight
51-
char line_buf[64];
51+
char line_buf[80];
5252

5353
for (int y = 0; y < 4; y++) {
5454
int buf_pos = 0;
55-
for (int x = 0; x < 12; x++) {
55+
for (int x = 0; x < 15; x++) {
5656
char c = keyboard[y][x];
5757
if (c == 0) break;
5858

@@ -133,7 +133,7 @@ void vblank_isr() {
133133

134134
if (vblanks_since_chunk >= 90) {
135135
setup_next_chunk();
136-
vblanks_since_chunk = 0;
136+
vblanks_since_chunk = 0;
137137
}
138138
}
139139
}
@@ -153,7 +153,7 @@ short *write_wav(short *iwave, long length) {
153153
}
154154
return iwave;
155155
}
156-
156+
157157
void stop_audio() {
158158
if (!audio_playing) return;
159159

@@ -238,6 +238,15 @@ int main(void) {
238238

239239
TextToSpeechInit(write_wav, NULL);
240240

241+
// Enable phoneme mode by default
242+
TextToSpeechStart("[:phoneme on]", NULL, WAVE_FORMAT_1M16);
243+
TextToSpeechSync();
244+
245+
// Reset audio state after init
246+
audio_length = 0;
247+
total_samples_received = 0;
248+
play_position = 0;
249+
241250
draw_screen();
242251

243252
while (1) {
@@ -249,15 +258,15 @@ int main(void) {
249258
cursor_y = (cursor_y - 1 + 4) % 4;
250259
// Clamp cursor_x to valid range for new row
251260
int row_len = 0;
252-
while (keyboard[cursor_y][row_len] != 0 && row_len < 12) row_len++;
261+
while (keyboard[cursor_y][row_len] != 0 && keyboard[cursor_y][row_len] != ' ' && row_len < 15) row_len++;
253262
if (cursor_x >= row_len) cursor_x = row_len - 1;
254263
draw_screen();
255264
}
256265
if (key_hit(KEY_DOWN)) {
257266
cursor_y = (cursor_y + 1) % 4;
258267
// Clamp cursor_x to valid range for new row
259268
int row_len = 0;
260-
while (keyboard[cursor_y][row_len] != 0 && row_len < 12) row_len++;
269+
while (keyboard[cursor_y][row_len] != 0 && keyboard[cursor_y][row_len] != ' ' && row_len < 15) row_len++;
261270
if (cursor_x >= row_len) cursor_x = row_len - 1;
262271
draw_screen();
263272
}
@@ -266,7 +275,7 @@ int main(void) {
266275
if (cursor_x < 0) {
267276
// Get length of current row
268277
int row_len = 0;
269-
while (keyboard[cursor_y][row_len] != 0 && row_len < 12) row_len++;
278+
while (keyboard[cursor_y][row_len] != 0 && keyboard[cursor_y][row_len] != ' ' && row_len < 15) row_len++;
270279
cursor_x = row_len - 1;
271280
}
272281
draw_screen();
@@ -275,7 +284,7 @@ int main(void) {
275284
cursor_x++;
276285
// Get length of current row
277286
int row_len = 0;
278-
while (keyboard[cursor_y][row_len] != 0 && row_len < 12) row_len++;
287+
while (keyboard[cursor_y][row_len] != 0 && keyboard[cursor_y][row_len] != ' ' && row_len < 15) row_len++;
279288
if (cursor_x >= row_len) cursor_x = 0;
280289
draw_screen();
281290
}
@@ -285,7 +294,7 @@ int main(void) {
285294
char c = keyboard[cursor_y][cursor_x];
286295
if (c == '\x7F') {
287296
backspace_input();
288-
} else if (c != 0) {
297+
} else if (c != 0 && c != ' ') {
289298
add_char_to_input(c);
290299
}
291300
}

0 commit comments

Comments
 (0)