DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
battle_globals.cpp
1#pragma helper_mask_gpr 0x30
2#pragma helper_mask_fpr 0x1000
3#pragma name_counter 15
4
5#include "battle_globals.hpp"
6
7#include <cmath>
8#include <cstdio>
9#include <cstdlib>
10
11#include "clsmes.hpp"
12#include "dataread.hpp"
13#include "gamepad.hpp"
14#include "mainselect.hpp"
15#include "memcard.hpp"
16#include "menu_draw.hpp"
17#include "menu_inventory.hpp"
18#include "rect.hpp"
19#include "runscript.hpp"
20#include "savedata.hpp"
21#include "texture.hpp"
22
26// clang-format off
27enum NameInputMode {
28 NAME_INPUT_KATAKANA = 0,
29 NAME_INPUT_HIRAGANA = 1,
30 NAME_INPUT_ALPHABET = 2,
31 NAME_INPUT_SYMBOL = 3,
32};
33
34// clang-format on
35
39// clang-format off
40enum NameSelectArea {
41 NAME_AREA_KEYBOARD = 4,
42 NAME_AREA_TABS = 5,
43 NAME_AREA_HELP = 6,
44 NAME_AREA_CONFIRM = 7,
45 NAME_AREA_EMPTY_NOTICE = 8,
46};
47
48// clang-format on
49
53// clang-format off
54enum NameSelectState {
55 NAME_STATE_IDLE = 0,
56 NAME_STATE_FADE_IN = 1,
57 NAME_STATE_FADE_OUT = 2,
58 NAME_STATE_EXIT = 3,
59 NAME_STATE_TAB_FLASH = 6,
60 NAME_STATE_HELP = 8,
61};
62
63// clang-format on
64
68// clang-format off
69enum NameSelectTab {
70 NAME_TAB_KATAKANA = 0,
71 NAME_TAB_HIRAGANA = 1,
72 NAME_TAB_ALPHABET = 2,
73 NAME_TAB_SYMBOL = 3,
74 NAME_TAB_DEFAULT_NAME = 4,
75 NAME_TAB_OK = 5,
76 NAME_TAB_LEFT = 6,
77 NAME_TAB_RIGHT = 7,
78 NAME_TAB_DELETE = 8,
79 NAME_TAB_INSERT = 9,
80 NAME_TAB_HELP = 10,
81};
82
83// clang-format on
84
88// clang-format off
89enum NameEnterAction {
90 NAME_ACTION_NONE = -1,
91 NAME_ACTION_DECIDE = 49,
92 NAME_ACTION_FINISH = 50,
93 NAME_ACTION_INPUT = 100,
94 NAME_ACTION_DELETE = 200,
95 NAME_ACTION_BACKSPACE = 250,
96 NAME_ACTION_INSERT = 300,
97 NAME_ACTION_NEXT_MODE = 400,
98 NAME_ACTION_PREV_MODE = 450,
99 NAME_ACTION_LEFT = 500,
100 NAME_ACTION_RIGHT = 600,
101 NAME_ACTION_DEFAULT_NAME = 700,
102 NAME_ACTION_HELP = 800,
103 NAME_ACTION_TOGGLE_VOICING = 900,
104};
105
106// clang-format on
107
128
129STATIC_ASSERT(sizeof(NAME_SELECT) == 0x2C);
130
132NAME_SELECT NameSelect;
133
135extern "C" {
136s16 *CharaName;
137}
138
140CTexture *CharaFace;
141
143CTexture *NameTemp;
144
146CTexture *HiraTex;
147
149CTexture *KataTex;
150
152CTexture *AlphaTex;
153
154#ifdef PAL
156CTexture *EuroTex;
157
159s8 InputModeOrikaeshi[4] = {10, 10, 13, 10};
160
162s8 InputModeMovetbl[4][2] = {
163 {0x26, 0x1A},
164 {0x26, 0x1A},
165 {0x22, 0x1A},
166 {0x26, 0x1A}
167};
168#else
170s16 InputModeMovetbl[4][2] = {
171 {0x26, 0x1A},
172 {0x26, 0x1A},
173 {0x22, 0x1E},
174 {0x26, 0x1A}
175};
176
178s16 InputModeOrikaeshi[4] = {10, 10, 13, 10};
179#endif
180
181#include "gameutil.hpp"
182#include "snd.hpp"
183
191void GlobalNameInit() {
192 for (int chara_no = 0; chara_no < 6; chara_no++) {
193 NameDefaultSet(chara_no);
194 }
195}
196
204void InitNameRegist(int chara_no, int texture_block, u_long128 *buffer) {
205 StartReadBG();
206
207 if (buffer == NULL) {
208 buffer = (u_long128 *) read_buffer;
209 } else {
210 buffer = (u_long128 *) buffer;
211 }
212
213 LoadFileBGMenuData("nameregi.pak", MenuCalcBufAlignment(buffer));
214 NameSelect.language = GetMenuLangFlag();
215 GamePad.MenuModeOn(0x78);
216 GamePad.SetAutoRepeat(PAD_DPAD, 30, 9);
217
218 NameSelect.chara_no = chara_no;
219 NameSelect.area = NAME_AREA_KEYBOARD;
220 NameSelect.cursor = 0;
221
222 switch (NameSelect.language) {
223 case LANG_JAPANESE:
224 NameSelect.input_mode = NAME_INPUT_KATAKANA;
225 break;
226#ifndef PAL
227 case LANG_ENGLISH_US:
228#endif
229 default:
230 NameSelect.input_mode = NAME_INPUT_ALPHABET;
231 break;
232 }
233
234 NameSelect.side_row = 0;
235 NameSelect.state = NAME_STATE_FADE_IN;
236 NameSelect.state_count = 0;
237 NameSelect.loaded = false;
238 NameSelect.texture_block = texture_block;
239 NameSelect.cursor_x = 100.0f;
240 NameSelect.cursor_y = 242.0f;
241 NameSelect.frame = 0;
242 CharaName = SaveData->GetCharaName(NameSelect.chara_no);
243 NameDefaultSet(NameSelect.chara_no);
244 NameSelect.name_pos = 0;
245}
246
254void ExitNameEnterFunc() {
255 int texture_blocks[2] = {NameSelect.texture_block, -1};
256 MenuTextureDelete(texture_blocks);
257 TexManager.CleanUpTextureList();
258 GamePad.AutoRepeatOff();
259 GamePad.MenuModeOff();
260}
261
269CTexture *GetNameTextureInfo(CTexture **textures, int char_code, int &cell_x, int &cell_y) {
270 CTexture *texture;
271
272 if (char_code == 0) {
273 char_code = 0xE6;
274 texture = textures[0];
275 } else if (char_code < 0x52) {
276 char_code -= 1;
277 texture = textures[1];
278 } else if (char_code < 0xA2) {
279 char_code -= 0x52;
280 texture = textures[2];
281#ifdef PAL
282 } else if (char_code < 0x104) {
283 char_code -= 0xA2;
284 texture = textures[0];
285 } else {
286 char_code -= 0x104;
287 texture = textures[3];
288 }
289
290#else
291 } else {
292 char_code -= 0xA2;
293 texture = textures[0];
294 }
295
296#endif
297 cell_x = (char_code % 10) * 0x16;
298 cell_y = (char_code / 10) * 0x16;
299 return texture;
300}
301
309void DrawCharaName(int chara_no, int x, int y, int brightness, int blend_mode) {
310 int draw_x = x;
311#ifdef PAL
312 CTexture *textures[4] = {AlphaTex, KataTex, HiraTex, EuroTex};
313#else
314 CTexture *textures[3] = {AlphaTex, KataTex, HiraTex};
315#endif
316
317 for (int slot = 0; slot < 10; slot++) {
318 int cell_x;
319 int cell_y;
320 CTexture *texture = GetNameTextureInfo(textures, CharaName[slot], cell_x, cell_y);
321 DrawMenu2DSprite(texture, CRect_i_(draw_x, y, 22, 22), CRect_i_(cell_x, cell_y, 22, 22), brightness, brightness, brightness, blend_mode);
322 draw_x += 22;
323 }
324}
325
333void DrawNameRegiWaku(int x, int y, int size, int brightness, int blend_mode) {
334 float inset = 0.1f * (NameSelect.frame % 29);
335 int edge[4];
336
337 edge[0] = x + inset;
338 edge[1] = y + inset;
339 edge[2] = x + size - inset;
340 edge[3] = y + size - inset;
341 s16 corner[4][2] = {
342 {edge[0], edge[1]},
343 {edge[2], edge[1]},
344 {edge[0], edge[3]},
345 {edge[2], edge[3]}
346 };
347 s16 cell[4][2] = {
348 {480, 296},
349 {496, 296},
350 {480, 312},
351 {496, 312}
352 };
353
354 for (int corner_no = 0; corner_no < 4; corner_no++) {
355 DrawMenu2DSprite(NameTemp, CRect_i_(corner[corner_no][0], corner[corner_no][1], 12, 12), CRect_i_(cell[corner_no][0], cell[corner_no][1], 16, 16), (u8) brightness, (u8) brightness, (u8) brightness, blend_mode);
356 }
357}
358
366void DrawCharaNameUp(int x, int y, int brightness, int blend_mode) {
367 int left;
368 int top;
369 int chara_no = NameSelect.chara_no;
370 left = x - 2;
371 top = y + 14;
372 int face_x = 0;
373 int face_y = chara_no * 106;
374 int name_length;
375
376 if (chara_no > 2) {
377 face_x = 106;
378 face_y = (chara_no - 3) * 106;
379 }
380
381 DrawMenu2DSprite(CharaFace, CRect_i_(left, top, 88, 88), CRect_i_(face_x, face_y, 106, 106), blend_mode);
382 DrawMenuHelpWindow(TexManager.GetTexture("window", -1), -1, left + 102, top + 16, 8.6f, 1.0f, blend_mode);
383 DrawMenu2DSprite(NameTemp, CRect_i_(left + 97, top + 16, 26, 23), CRect_i_(0, 256, 26, 24), (u8) brightness, (u8) brightness, (u8) brightness, blend_mode);
384 DrawMenu2DSprite(NameTemp, CRect_i_(left + 123, top + 16, 210, 23), CRect_i_(26, 256, 172, 24), (u8) brightness, (u8) brightness, (u8) brightness, blend_mode);
385 DrawMenu2DSprite(NameTemp, CRect_i_(left + 333, top + 16, 26, 23), CRect_i_(198, 256, 26, 24), (u8) brightness, (u8) brightness, (u8) brightness, blend_mode);
386
387 MenuTextureReload(AtoraNameMes.tex_block);
388 int message_length = AtoraNameMes.GetMesLen_system(chara_no - 1220);
389 float char_width[7] = {18.0f, 12.0f, 12.0f, 12.0f, 12.0f, 12.0f, 12.0f};
390 float title_char_width = char_width[NameSelect.language];
391 AtoraNameMes.line_pos[0].x = 290.0f - title_char_width * (message_length / 2.0f);
392 AtoraNameMes.line_pos[0].y = 82;
393 AtoraNameMes.edge_alpha = blend_mode;
394 AtoraNameMes.Step();
395 AtoraNameMes.DrawMesWin();
396 MenuTextureReload(NameSelect.texture_block);
397
398 if (NameSelect.area < NAME_AREA_HELP) {
399 CRect_i_ destination(left + 89, top + 25, 24, 24);
400 CRect_i_ source(24, 472, 24, 24);
401 DrawMenu2DSprite(NameTemp, destination, source, blend_mode);
402 source.x += 25;
403 destination.x = left + 331;
404 DrawMenu2DSprite(NameTemp, destination, source, blend_mode);
405 }
406
407 left = x + 120;
408 top = y + 58;
409 DrawCharaName(chara_no, left, top, brightness, blend_mode);
410
411 left = x + 122;
412 top = y + 82;
413
414 if (NameSelect.area == NAME_AREA_CONFIRM) {
415 for (name_length = 10; name_length > 0; name_length--) {
416 if (CharaName[name_length - 1] != 0 && CharaName[name_length - 1] != 0xE6) {
417 break;
418 }
419 }
420 }
421
422 for (int slot = 0; slot < 10; slot++) {
423 int underline_brightness = brightness;
424
425 if (NameSelect.area == NAME_AREA_CONFIRM && name_length <= slot) {
426 underline_brightness = 0x38;
427 }
428
429 DrawMenu2DSprite(NameTemp, CRect_i_(left, top, 18, 2), CRect_i_(470, 328, 18, 2), (u8) underline_brightness, (u8) underline_brightness, (u8) underline_brightness, blend_mode);
430 left += 22;
431 }
432
433 int cursor_slot = NameSelect.name_pos;
434
435 if (cursor_slot >= 10) {
436 cursor_slot = 9;
437 }
438
439 left = x + 110 + cursor_slot * 22;
440 top = y + 48;
441
442 switch (NameSelect.state) {
443 case NAME_STATE_FADE_IN:
444 case NAME_STATE_FADE_OUT:
445 break;
446 default:
447 if (NameSelect.area < NAME_AREA_HELP) {
448 DrawNameRegiWaku(left, top, 30, brightness, blend_mode);
449 int bob_frame = NameSelect.frame - 15;
450
451 if (NameSelect.area >= NAME_AREA_HELP) {
452 bob_frame = 0;
453 }
454
455 top = (top - 20) + 4.0f * sinf(0.20943952f * (bob_frame % 31));
456 DrawMenu2DSprite(NameTemp, CRect_i_(left + 20, top, 24, 24), CRect_i_(488, 328, 24, 24), (u8) brightness, (u8) brightness, (u8) brightness, blend_mode);
457 }
458
459 break;
460 }
461}
462
463#ifdef PAL
465s8 menu_kigoutbl[40] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 17, 18, 19, 20, 21, 41, 42, 43, 44, 16, 16, 16, 16, 16, 16, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37};
466
468s16 menu_euro_codetbl[5][2][13] = {
469 {
470 {260, 261, 262, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1},
471 {260, 261, 262, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1},
472 },
473 {
474 {260, 290, 270, 300, 280, 265, 295, 275, 305, 285, -2, -1, -1},
475 {262, 292, 282, 267, 297, 287, 291, 296, 312, 313, -2, -1, -1},
476 },
477 {
478 {260, 300, 280, 265, 305, 285, 320, -2, -1, -1, -1, -1, -1},
479 {-1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1},
480 },
481 {
482 {261, 291, 271, 301, 281, 266, 296, 276, 306, 286, -2, -1, -1},
483 {262, 292, 272, 302, 282, 267, 297, 277, 307, 285, -1, -1, 0},
484 },
485 {
486 {261, 291, 271, 301, 281, 266, 296, 276, 306, 286, 280, 285, -2},
487 {-1, -1, -1, -2, -1, -1, -2, -1, -1, -1, -1, -1, -1},
488 },
489};
490
492s8 euro_code_linelimmit[5] = {2, 2, 1, 2, 1};
493#endif
494
495#ifdef PAL
496void DrawEuroSpecialFont(int x, int y, int language, int brightness, int blend_mode) {
497 int key_x;
498 int key_y;
499 int cell_x;
500 int cell_y;
501 int row;
502 int column;
503
504 EuroTex = TexManager.GetTexture("euro", -1);
505
506 for (row = 0; row < 2; row++) {
507 for (column = 0; column < 13; column++) {
508 int key = column + row * 13;
509
510 if (key >= 26) {
511 break;
512 }
513
514 int char_code = menu_euro_codetbl[language][0][key] - 0x104;
515
516 if (char_code == -2) {
517 break;
518 }
519
520 if (char_code >= 0) {
521 cell_x = (char_code % 10) * 22;
522 cell_y = (char_code / 10) * 22;
523 key_x = x + column * 34;
524 key_y = y + row * 26;
525 DrawMenu2DSprite(EuroTex, CRect_i_(key_x + 1, key_y + 1, 22, 22), CRect_i_(cell_x, cell_y, 22, 23), 0, 0, 0, (blend_mode * 80) >> 7);
526 DrawMenu2DSprite(EuroTex, CRect_i_(key_x, key_y, 22, 22), CRect_i_(cell_x, cell_y, 22, 23), (u8) brightness, (u8) brightness, (u8) brightness, blend_mode);
527 }
528 }
529 }
530}
531#endif
532
533#ifdef PAL
541static s16 Get_NameTemp_PutX(int language, int tab) {
542 s16 tab_x[7][11] = {
543 {40, 125, 209, 261, 311, 378, 40, 74, 111, 168, 223},
544 {0, 0, 40, 223, 303, 384, 40, 74, 111, 168, 223},
545 {0, 0, 40, 144, 303, 384, 40, 74, 111, 168, 223},
546 {0, 0, 40, 140, 303, 384, 40, 74, 111, 168, 223},
547 {0, 0, 40, 150, 303, 384, 40, 74, 111, 168, 223},
548 {0, 0, 40, 142, 303, 384, 40, 74, 111, 168, 223},
549 {0, 0, 40, 132, 283, 384, 40, 74, 111, 168, 223},
550 };
551 return tab_x[language][tab];
552}
553#endif
554
555char NameEntryImageDescriptor[] __attribute__((section(".rodata"))) = "#frame_image_name#640#" SCREEN_HEIGHT_STR "#4";
556char NameEntryTextureFile[] __attribute__((section(".rodata"))) = "nameregi.img";
557char NameEntryTempTexture[] __attribute__((section(".rodata"))) = "nametemp";
558char NameEntryHiraganaTexture[] __attribute__((section(".rodata"))) = "hira";
559char NameEntryKatakanaTexture[] __attribute__((section(".rodata"))) = "kata";
560char NameEntryAlphabetTexture[] __attribute__((section(".rodata"))) = "alphabet";
561#ifdef PAL
562char NameEntryEuroTextureFormat[] __attribute__((section(".rodata"))) = "euro tex is %p\n";
563#endif
564char NameEntryFaceTexture[] __attribute__((section(".rodata"))) = "charaface";
565char NameEntryMessageFile[] __attribute__((section(".rodata"))) = "nameregi.bin";
566char NameEntryMessageFile2[] __attribute__((section(".rodata"))) = "nameregi2.bin";
567char NameEntryFrameTexture[] __attribute__((section(".rodata"))) = "frame_image";
568
576#ifdef PAL
577static void DrawNameTemplete(int x, int y, int brightness, int blend_mode) {
578 int input_mode = NameSelect.input_mode;
579 int pushed_tab = NameSelect.pushed_tab;
580 int draw_x;
581 int draw_y;
582 int tex_u;
583 int tex_v;
584 int i;
585 int key_x;
586 int key_y;
587 s16 key_count[4] = {89, 88, 52, 40};
588
589 DrawMenu2DSprite(NameTemp, CRect_i_(x, y, 0x200, 0x100), CRect_i_(0, 0, 0x200, 0x100), brightness, brightness, brightness, blend_mode);
590
591 int language = NameSelect.language;
592 int tab_height = 0x18;
593 u8 tab_width[7][11] = {
594 {78, 78, 44, 44, 60, 52, 24, 24, 48, 48, 112},
595 {0, 0, 176, 75, 74, 70, 24, 24, 48, 48, 112},
596 {0, 0, 96, 155, 74, 70, 24, 24, 48, 48, 112},
597 {0, 0, 92, 159, 76, 70, 24, 24, 48, 48, 112},
598 {0, 0, 103, 148, 74, 70, 24, 24, 48, 48, 112},
599 {0, 0, 94, 157, 75, 70, 24, 24, 48, 48, 112},
600 {0, 0, 86, 145, 95, 70, 24, 24, 48, 48, 112},
601 };
602
603 if (NameSelect.state == NAME_STATE_TAB_FLASH) {
604 draw_x = x + Get_NameTemp_PutX(language, pushed_tab);
605 draw_y = y + 6 + (pushed_tab / 6) * 27;
606
607 tex_u = 0;
608
609 if (pushed_tab < 6) {
610 i = 0;
611 tex_v = 0x148;
612 } else {
613 i = 6;
614 tex_v = 0x160;
615 }
616
617 for (; i < pushed_tab; i++) {
618 tex_u += tab_width[language][i];
619 }
620
621 if (pushed_tab == NAME_TAB_OK) {
622 draw_y += 4;
623 tab_height = 0x28;
624 }
625
626 DrawMenu2DSprite(NameTemp, CRect_i_(draw_x, draw_y, tab_width[language][pushed_tab], tab_height), CRect_i_(tex_u, tex_v, tab_width[language][pushed_tab], tab_height), brightness, brightness, brightness, blend_mode);
627 }
628
629 draw_x = x + Get_NameTemp_PutX(language, input_mode);
630 draw_y = y + 6;
631
632 for (i = 0, tex_u = 0; i < input_mode; i++) {
633 tex_u += tab_width[language][i];
634 }
635
636 DrawMenu2DSprite(NameTemp, CRect_i_(draw_x, draw_y, tab_width[language][input_mode], 0x18), CRect_i_(tex_u, 0x148, tab_width[language][input_mode], 0x18), brightness, brightness, brightness, blend_mode);
637
638 int base_x = x + 0x38;
639 int base_y = y + 0x54;
640 CTexture *texture;
641
642 draw_y = base_y;
643
644 if (input_mode == NAME_INPUT_KATAKANA) {
645 texture = KataTex;
646 }
647
648 if (input_mode == NAME_INPUT_HIRAGANA) {
649 texture = HiraTex;
650 }
651
652 switch (input_mode) {
653 case NAME_INPUT_KATAKANA:
654 case NAME_INPUT_HIRAGANA:
655 draw_x = base_x - 8;
656
657 for (int key = 0; key < key_count[input_mode]; key++) {
658 tex_u = (key % 10) * 22;
659 tex_v = (key / 10) * 22;
660
661 CRect_i_ tex_rect(tex_u, tex_v, 22, 23);
662
663 DrawMenu2DSprite(texture, CRect_i_(draw_x + 1, draw_y + 1, 22, 22), tex_rect, 0, 0, 0, (blend_mode * 0x50) >> 7);
664 DrawMenu2DSprite(texture, CRect_i_(draw_x, draw_y, 22, 22), tex_rect, brightness, brightness, brightness, blend_mode);
665
666 if (key < 0x23 && key != 0x1D) {
667 draw_x += 0x26;
668
669 if (key % 5 == 4) {
670 draw_x -= 0xBE;
671 draw_y += 0x1A;
672 }
673 } else if (key >= 0x50) {
674 draw_y += 0x1A;
675 } else {
676 switch (key) {
677 case 0x1D:
678 draw_x = base_x + 0xCA;
679 draw_y = base_y;
680 break;
681 case 0x23:
682 case 0x24:
683 case 0x2B:
684 case 0x2C:
685 draw_x += 0x4C;
686 break;
687 case 0x31:
688 draw_x -= 0x72;
689 draw_y += 0x1A;
690 break;
691 case 0x25:
692 case 0x2A:
693 case 0x2D:
694 draw_x -= 0x98;
695 draw_y += 0x1A;
696 break;
697 case 0x36:
698 draw_y = base_y;
699
700 if (input_mode == NAME_INPUT_KATAKANA) {
701 key = 0x50;
702 }
703
704 if (input_mode == NAME_INPUT_HIRAGANA) {
705 key = 0x4F;
706 }
707 default:
708 draw_x += 0x26;
709 break;
710 }
711 }
712 }
713
714 break;
715 case NAME_INPUT_ALPHABET:
716 draw_x = base_x - 0xE;
717
718 // The European keyboards move up to make room for their accented rows.
719 if (NameSelect.language > LANG_ENGLISH_UK) {
720 base_y += euro_code_linelimmit[NameSelect.language - 2] * -3;
721 }
722
723 for (int key = 0; key < 0x34; key++) {
724 tex_u = (key % 10) * 22;
725 tex_v = (key / 10) * 22;
726
727 CRect_i_ tex_rect(tex_u, tex_v, 22, 23);
728 key_x = draw_x + (key % 13) * 34;
729
730 key_y = base_y + (key / 13) * 26;
731 DrawMenu2DSprite(AlphaTex, CRect_i_(key_x + 1, key_y + 1, 22, 22), tex_rect, 0, 0, 0, (blend_mode * 0x50) >> 7);
732 DrawMenu2DSprite(AlphaTex, CRect_i_(key_x, key_y, 22, 22), tex_rect, brightness, brightness, brightness, blend_mode);
733 }
734
735 if (NameSelect.language > LANG_ENGLISH_UK) {
736 DrawEuroSpecialFont(draw_x, key_y + 26, NameSelect.language - 2, brightness, blend_mode);
737 }
738
739 break;
740 case NAME_INPUT_SYMBOL:
741 for (int key = 0; key < key_count[3]; key++) {
742 int cell_no = menu_kigoutbl[key] + 2;
743
744 if (cell_no >= 0) {
745 tex_u = (cell_no % 10) * 22;
746 tex_v = (cell_no / 10) * 22 + 0x6E;
747 key_x = base_x + (key % 10) * 38;
748 key_y = base_y + (key / 10) * 26;
749 DrawMenu2DSprite(AlphaTex, CRect_i_(key_x, key_y, 22, 22), CRect_i_(tex_u, tex_v, 22, 23), brightness, brightness, brightness, blend_mode);
750 }
751 }
752
753 break;
754 }
755}
756#else
757static void DrawNameTemplete(int x, int y, int brightness, int blend_mode) {
758 int input_mode = NameSelect.input_mode;
759 int pushed_tab = NameSelect.pushed_tab;
760 int draw_x;
761 int draw_y;
762 int tex_u;
763 int tex_v;
764 int i;
765 s16 key_count[4] = {89, 88, 62, 24};
766
767 DrawMenu2DSprite(NameTemp, CRect_i_(x, y, 0x200, 0x100), CRect_i_(0, 0, 0x200, 0x100), brightness, brightness, brightness, blend_mode);
768
769 int language = NameSelect.language;
770
771 if (language > LANG_JAPANESE) {
772 language = LANG_ENGLISH_US;
773 }
774
775 s16 tab_x[2][11] = {
776 {40, 125, 209, 261, 311, 378, 40, 74, 111, 168, 223},
777 {0, 0, 40, 223, 303, 384, 40, 74, 111, 168, 223},
778 };
779 s16 tab_width[2][11] = {
780 {78, 78, 44, 44, 60, 52, 24, 24, 48, 48, 112},
781 {0, 0, 176, 75, 74, 70, 24, 24, 48, 48, 112},
782 };
783 int tab_height = 0x18;
784
785 if (NameSelect.state == NAME_STATE_TAB_FLASH) {
786 draw_x = x + tab_x[language][pushed_tab];
787 draw_y = y + 6 + (pushed_tab / 6) * 27;
788
789 tex_u = 0;
790
791 if (pushed_tab < 6) {
792 i = 0;
793 tex_v = 0x148;
794 } else {
795 i = 6;
796 tex_v = 0x160;
797 }
798
799 for (; i < pushed_tab; i++) {
800 tex_u += tab_width[language][i];
801 }
802
803 if (pushed_tab == NAME_TAB_OK) {
804 draw_y += 4;
805 tab_height = 0x28;
806 }
807
808 DrawMenu2DSprite(NameTemp, CRect_i_(draw_x, draw_y, tab_width[language][pushed_tab], tab_height), CRect_i_(tex_u, tex_v, tab_width[language][pushed_tab], tab_height), brightness, brightness, brightness, blend_mode);
809 }
810
811 draw_x = x + tab_x[language][input_mode];
812 draw_y = y + 6;
813
814 for (i = 0, tex_u = 0; i < input_mode; i++) {
815 tex_u += tab_width[language][i];
816 }
817
818 DrawMenu2DSprite(NameTemp, CRect_i_(draw_x, draw_y, tab_width[language][input_mode], 0x18), CRect_i_(tex_u, 0x148, tab_width[language][input_mode], 0x18), brightness, brightness, brightness, blend_mode);
819
820 int base_x = x + 0x38;
821 int base_y = y + 0x54;
822 CTexture *texture;
823
824 draw_y = base_y;
825
826 if (input_mode == NAME_INPUT_KATAKANA) {
827 texture = KataTex;
828 }
829
830 if (input_mode == NAME_INPUT_HIRAGANA) {
831 texture = HiraTex;
832 }
833
834 switch (input_mode) {
835 case NAME_INPUT_KATAKANA:
836 case NAME_INPUT_HIRAGANA:
837 draw_x = base_x - 8;
838
839 for (int key = 0; key < key_count[input_mode]; key++) {
840 tex_u = (key % 10) * 22;
841 tex_v = (key / 10) * 22;
842
843 CRect_i_ tex_rect(tex_u, tex_v, 22, 23);
844
845 DrawMenu2DSprite(texture, CRect_i_(draw_x + 1, draw_y + 1, 22, 22), tex_rect, 0, 0, 0, (blend_mode * 0x50) >> 7);
846 DrawMenu2DSprite(texture, CRect_i_(draw_x, draw_y, 22, 22), tex_rect, brightness, brightness, brightness, blend_mode);
847
848 if (key < 0x23 && key != 0x1D) {
849 draw_x += 0x26;
850
851 if (key % 5 == 4) {
852 draw_x -= 0xBE;
853 draw_y += 0x1A;
854 }
855 } else if (key >= 0x50) {
856 draw_y += 0x1A;
857 } else {
858 switch (key) {
859 case 0x1D:
860 draw_x = base_x + 0xCA;
861 draw_y = base_y;
862 break;
863 case 0x23:
864 case 0x24:
865 case 0x2B:
866 case 0x2C:
867 draw_x += 0x4C;
868 break;
869 case 0x31:
870 draw_x -= 0x72;
871 draw_y += 0x1A;
872 break;
873 case 0x25:
874 case 0x2A:
875 case 0x2D:
876 draw_x -= 0x98;
877 draw_y += 0x1A;
878 break;
879 case 0x36:
880 draw_y = base_y;
881
882 if (input_mode == NAME_INPUT_KATAKANA) {
883 key = 0x50;
884 }
885
886 if (input_mode == NAME_INPUT_HIRAGANA) {
887 key = 0x4F;
888 }
889 default:
890 draw_x += 0x26;
891 break;
892 }
893 }
894 }
895
896 break;
897 case NAME_INPUT_ALPHABET:
898 draw_x = base_x - 0xE;
899
900 for (int key = 0; key < key_count[2]; key++) {
901 tex_u = (key % 10) * 22;
902 tex_v = (key / 10) * 22;
903
904 if (key > 0x33) {
905 tex_u = (key - 0x34) * 22;
906 tex_v = 0xB0;
907 }
908
909 CRect_i_ tex_rect(tex_u, tex_v, 22, 23);
910
911 DrawMenu2DSprite(AlphaTex, CRect_i_(draw_x + 1, draw_y + 1, 22, 22), tex_rect, 0, 0, 0, (blend_mode * 0x50) >> 7);
912 DrawMenu2DSprite(AlphaTex, CRect_i_(draw_x, draw_y, 22, 22), tex_rect, brightness, brightness, brightness, blend_mode);
913 draw_x += 0x22;
914
915 if (key < 0x1A) {
916 if (key % 13 == 12) {
917 draw_y += 0x1A;
918 draw_x -= 0x1BA;
919 }
920
921 if (key == 0x19) {
922 draw_x = base_x - 0xE;
923 }
924 } else if (key < 0x34) {
925 int lower_key = key - 0x1A;
926
927 if (lower_key % 13 == 12) {
928 draw_x -= 0x1BA;
929 draw_y += 0x1E;
930 }
931
932 if (lower_key == 0x19) {
933 draw_x = base_x - 0xE;
934 }
935 }
936 }
937
938 break;
939 case NAME_INPUT_SYMBOL:
940 draw_x = base_x;
941
942 for (int key = 0; key < key_count[3]; key++) {
943 int cell_no = key + 2;
944 int row = key / 10;
945
946 if (key >= 0xC && key < 0xF) {
947 cell_no += 1;
948 }
949
950 if (key >= 0xF && key < 0x14) {
951 cell_no += 2;
952 }
953
954 if (key >= 0x14) {
955 cell_no = key + 0x17;
956 }
957
958 tex_u = (cell_no % 10) * 22;
959 tex_v = (cell_no / 10) * 22 + 0x6E;
960 DrawMenu2DSprite(AlphaTex, CRect_i_(draw_x, draw_y, 22, 22), CRect_i_(tex_u, tex_v, 22, 23), brightness, brightness, brightness, blend_mode);
961 draw_x += 0x26;
962
963 if (key % 10 == 9) {
964 draw_x -= 0x17C;
965 draw_y += 0x1A;
966 }
967 }
968
969 break;
970 }
971}
972#endif
973
981static int NameCompare(short *first, short *second) {
982 int matching = 0;
983
984 for (int i = 0; i < 10; i++) {
985 if (first[i] == second[i]) {
986 matching++;
987 }
988 }
989
990 // Every character has to agree before the names count as one.
991 if (matching >= 10) {
992 return 0;
993 }
994
995 return 1;
996}
997
1005int CheckName() {
1006 s16 blank_names[2][10] = {
1007 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
1008 {230, 230, 230, 230, 230, 230, 230, 230, 230, 230},
1009 };
1010 int blank_count = 0;
1011
1012 for (int slot = 0; slot < 10; slot++) {
1013 if (CharaName[slot] == 0 || CharaName[slot] == 230) {
1014 blank_count++;
1015 }
1016 }
1017
1018 if (blank_count >= 10) {
1019 return NAME_CHECK_EMPTY;
1020 }
1021
1022 for (int blank_no = 0; blank_no < 2; blank_no++) {
1023 if (NameCompare(CharaName, blank_names[blank_no]) == 0) {
1024 return NAME_CHECK_REJECTED;
1025 }
1026 }
1027
1028 for (int other_chara_no = NameSelect.chara_no - 1; 0 <= other_chara_no; other_chara_no--) {
1029 if (NameCompare(CharaName, SaveData->GetCharaName(other_chara_no)) == 0) {
1030 return NAME_CHECK_REJECTED;
1031 }
1032 }
1033
1034 return NAME_CHECK_OK;
1035}
1036
1044void NameEnterDraw() {
1045 int language;
1046 int chara_no;
1047 int fade;
1048 int brightness;
1049 float cursor_x;
1050 float cursor_y;
1051
1052 setbilinear(0);
1053
1054 if (NameSelect.chara_no != 0) {
1055 AllFadeForMenu(0x80);
1056 }
1057
1058 if (NameSelect.loaded == 0) {
1059 ReadBG();
1060
1061 if (ReadBGSync() == 0) {
1062 LOADTEXTURE_INFO2 info[3] = {
1063 {NameEntryImageDescriptor, 0, 0},
1064 {NULL, 0, 0},
1065 {NULL, 0, 0}
1066 };
1067
1068 info[0].block_no = NameSelect.texture_block;
1069 info[1].block_no = NameSelect.texture_block;
1070
1071 BG_READ_INFO *read_file = GetReadBGFile(0);
1072 info[1].name = (char *) GetPackFile((u_int *) read_file->buffer, NameEntryTextureFile, NULL);
1073 TexManager.DeleteTextureBlock(NameSelect.texture_block);
1074 TexManager.LoadTextureBlockEX(-1, info);
1075 NameTemp = TexManager.GetTexture(NameEntryTempTexture, -1);
1076 HiraTex = TexManager.GetTexture(NameEntryHiraganaTexture, -1);
1077 KataTex = TexManager.GetTexture(NameEntryKatakanaTexture, -1);
1078 AlphaTex = TexManager.GetTexture(NameEntryAlphabetTexture, -1);
1079#ifdef PAL
1080 EuroTex = TexManager.GetTexture("euro", -1);
1081 printf(NameEntryEuroTextureFormat, EuroTex);
1082#endif
1083 CharaFace = TexManager.GetTexture(NameEntryFaceTexture, -1);
1084 NameSelect.loaded = true;
1085
1086 short *messages = (short *) GetPackFile((u_int *) read_file->buffer, NameEntryMessageFile, NULL);
1087 short *messages2 = (short *) GetPackFile((u_int *) read_file->buffer, NameEntryMessageFile2, NULL);
1088 InitMenuMesSet(MENU_MES_SET_NAME_ENTRY, messages);
1089 CommonMenuMes2.SetBuff(messages2);
1090
1091 s8 char_size[7][2] = {
1092 {18, 22},
1093 {11, 20},
1094 {11, 20},
1095 {11, 20},
1096 {11, 20},
1097 {11, 20},
1098 {11, 20}
1099 };
1100 CommonMenuMes2.char_width = char_size[NameSelect.language][0];
1101 CommonMenuMes2.char_height = char_size[NameSelect.language][1];
1102 CommonMenuMes2.stay_frame = false;
1103 CommonMenuMes3.stay_frame = false;
1104 AtoraNameMes.mes_no[0] = NameSelect.chara_no + 0x3C;
1105 AtoraNameMes.MakeMesWin(0x1E);
1106 }
1107
1108 if (NameSelect.chara_no == 0) {
1109 return;
1110 }
1111 }
1112
1113 language = NameSelect.language;
1114 MenuTextureReload(NameSelect.texture_block);
1115 chara_no = NameSelect.chara_no;
1116 brightness = fade = 0x80;
1117
1118 switch (NameSelect.state) {
1119 case NAME_STATE_FADE_IN:
1120 fade = NameSelect.state_count * 5;
1121
1122 if (fade > 0x80) {
1123 fade = 0x80;
1124 NameSelect.state = NAME_STATE_IDLE;
1125 }
1126
1127 break;
1128 }
1129
1130 if (NameSelect.area >= NAME_AREA_HELP) {
1131 brightness = 0x38;
1132 }
1133
1134 CTexture *frame_texture = TexManager.GetTexture(NameEntryFrameTexture, -1);
1135
1136 if ((chara_no != 0 || NameSelect.loaded == 0) && frame_texture != NULL) {
1137 FrameImageDraw(0x80, 0x80);
1138 }
1139
1140 if (NameSelect.loaded != 0) {
1141 MenuTextureReload(NameSelect.texture_block);
1142 DrawMenu2DSprite(NameTemp, CRect_i_(0x30, 0x21, 0x3C, 0x27), CRect_i_(0x1C0, 0x100, 0x3C, 0x28), fade);
1143 DrawMenu2DSprite(NameTemp, CRect_i_(0x6E, 0x24, 0xAE, 0x1F), CRect_i_(0xC0, 0x178, 0xAE, 0x20), fade);
1144
1145 int name_color = brightness;
1146
1147 if (NameSelect.area >= NAME_AREA_HELP) {
1148 name_color = 0x80;
1149 }
1150
1151 DrawCharaNameUp(0x3E, 0x36, name_color, fade);
1152 DrawNameTemplete(0x42, 0x9E, brightness, fade);
1153
1154 switch (NameSelect.area) {
1155 case NAME_AREA_TABS:
1156 switch (language) {
1157 case LANG_JAPANESE: {
1158 s16 tab_x[11] = {88, 160, 252, 310, 358, 420, 88, 114, 154, 216, 268};
1159 cursor_x = tab_x[NameSelect.cursor];
1160 break;
1161 }
1162#ifdef PAL
1163 case LANG_ENGLISH_US: {
1164 s16 tab_x[11] = {88, 88, 88, 256, 350, 436, 88, 114, 154, 216, 268};
1165 cursor_x = tab_x[NameSelect.cursor];
1166 break;
1167 }
1168 default:
1169 cursor_x = (66.0f + Get_NameTemp_PutX(NameSelect.language, NameSelect.cursor)) - 28.0f;
1170 break;
1171#else
1172 default:
1173 case LANG_ENGLISH_US: {
1174 s16 tab_x[11] = {88, 88, 88, 256, 350, 436, 88, 114, 154, 216, 268};
1175 cursor_x = tab_x[NameSelect.cursor];
1176 break;
1177 }
1178#endif
1179 }
1180
1181 if (NameSelect.cursor < NAME_TAB_LEFT) {
1182 cursor_y = 164.0f;
1183
1184 if (NameSelect.cursor == NAME_TAB_OK) {
1185 cursor_y += 4.0f;
1186 }
1187 } else {
1188 cursor_y = 188.0f;
1189 }
1190
1191 break;
1192 case NAME_AREA_KEYBOARD: {
1193 int keys_per_row = InputModeOrikaeshi[NameSelect.input_mode];
1194 int step_x = InputModeMovetbl[NameSelect.input_mode][0];
1195 int step_y = InputModeMovetbl[NameSelect.input_mode][1];
1196 int cursor_key = NameSelect.cursor;
1197 int column = cursor_key % keys_per_row;
1198
1199 cursor_x = step_x * column + 0x62;
1200 cursor_y = step_y * (cursor_key / keys_per_row) + 0xEE;
1201
1202 if (NameSelect.input_mode < NAME_INPUT_ALPHABET) {
1203 cursor_x -= 8.0f;
1204
1205 if (column > 4) {
1206 cursor_x += 20.0f;
1207 }
1208
1209 if (NameSelect.side_row > 0) {
1210 cursor_x = step_x * keys_per_row + 0x6E;
1211 cursor_y = step_y * (NameSelect.side_row - 1) + 0xEE;
1212 }
1213 }
1214
1215 if (NameSelect.input_mode == NAME_INPUT_ALPHABET) {
1216 cursor_x -= 14.0f;
1217
1218#ifdef PAL
1219 if (NameSelect.language > LANG_ENGLISH_UK) {
1220 cursor_y += euro_code_linelimmit[NameSelect.language - 2] * -3;
1221 }
1222#endif
1223 }
1224
1225 break;
1226 }
1227 }
1228
1229 if (NameSelect.area < NAME_AREA_HELP) {
1230 if (abs((int) (cursor_x - NameSelect.cursor_x)) < 0x144) {
1231 NameSelect.cursor_x += (cursor_x - NameSelect.cursor_x) / 4.0f;
1232 NameSelect.cursor_y += (cursor_y - NameSelect.cursor_y) / 4.0f;
1233 } else {
1234 NameSelect.cursor_x = cursor_x;
1235 }
1236 }
1237
1238 switch (NameSelect.state) {
1239 case NAME_STATE_FADE_IN:
1240 case NAME_STATE_FADE_OUT:
1241 break;
1242 default: {
1243#ifdef PAL
1244 if (NameSelect.area == NAME_AREA_KEYBOARD && 230.0f <= NameSelect.cursor_y) {
1245#else
1246 if (NameSelect.area == NAME_AREA_KEYBOARD && 234.0f <= NameSelect.cursor_y) {
1247#endif
1248 DrawNameRegiWaku((int) (16.0f + cursor_x), (int) (cursor_y - 6.0f), 0x1C, brightness, fade);
1249 }
1250
1251#ifdef PAL
1252 // The hand sways on its own counter, which holds still while a tab flashes.
1253 static int lct = 0;
1254
1255 if (NameSelect.state != NAME_STATE_TAB_FLASH) {
1256 lct++;
1257 }
1258
1259 if (lct > 100000) {
1260 lct = 0;
1261 }
1262
1263 cursor_x = NameSelect.cursor_x + 5.0f * cosf(0.07853981852531433f * (float) lct);
1264 cursor_y = NameSelect.cursor_y + 3.0f * sinf(0.13089969754219055f * (float) lct);
1265
1266#else
1267 cursor_x = NameSelect.cursor_x + 5.0f * cosf(0.07853981852531433f * (float) NameSelect.frame);
1268 cursor_y = NameSelect.cursor_y + 3.0f * sinf(0.13089969754219055f * (float) NameSelect.frame);
1269
1270#endif
1271 if (NameSelect.area < NAME_AREA_EMPTY_NOTICE) {
1272 CRect_i_ hand_rect(0x1C0, 0x128, 0x20, 0x20);
1273
1274 DrawMenu2DSprite(NameTemp, CRect_i_((int) (2.0f + cursor_x), (int) (2.0f + cursor_y), 0x20, 0x20), hand_rect, 0, 0, 0, (fade * 0x50) >> 7);
1275 DrawMenu2DSprite(NameTemp, CRect_i_((int) cursor_x, (int) cursor_y, 0x20, 0x20), hand_rect, brightness, brightness, brightness, fade);
1276 }
1277
1278 break;
1279 }
1280 }
1281
1282 NameSelect.frame++;
1283
1284#ifdef PAL
1285 if (NameSelect.frame > 80000) {
1286#else
1287 if (NameSelect.frame > 500000) {
1288#endif
1289 NameSelect.frame = 0;
1290 }
1291
1292 CommonMenuMes3.text_x = 0x1B6;
1293 CommonMenuMes3.text_y = 0x58;
1294 DrawMenu2DSprite(NameTemp, CRect_i_(0x1A3, 0x46, 0xB8, 0x51), CRect_i_(0, 0x178, 0xC0, 0x61), 0x64, 0x64, 0x64, fade);
1295
1296 if (NameSelect.area >= NAME_AREA_HELP) {
1297 int win_x = 0xAE;
1298 int win_y = 0xAA;
1299 int win_width = 0x12C;
1300
1301 switch (NameSelect.area) {
1302 case NAME_AREA_CONFIRM:
1303 win_x = 0xD8;
1304 win_y = 0xB8;
1305 win_width = 0xDA;
1306 break;
1307 case NAME_AREA_EMPTY_NOTICE:
1308 win_x = 0xBA;
1309 win_y = 0xB8;
1310 win_width = 0x116;
1311 break;
1312 }
1313
1314 DrawMenu2DSprite(NameTemp, CRect_i_(win_x, win_y, win_width, 0x60), CRect_i_(0, 0x178, 0xC0, 0x61), 0x64, 0x64, 0x64, fade);
1315 CommonMenuMes2.text_x = win_x + 0x10;
1316 CommonMenuMes2.text_y = win_y + 0xE;
1317 }
1318
1319 MenuTextureReload(CommonMenuMes2.tex_block);
1320 CommonMenuMes3.edge_alpha = fade;
1321 CommonMenuMes3.Step();
1322 CommonMenuMes3.DrawMesWin();
1323
1324 switch (NameSelect.area) {
1325 case NAME_AREA_HELP:
1326 case NAME_AREA_CONFIRM:
1327 case NAME_AREA_EMPTY_NOTICE:
1328 CommonMenuMes2.edge_alpha = fade;
1329 CommonMenuMes2.Step();
1330 CommonMenuMes2.DrawMesWin();
1331 break;
1332 }
1333
1334 setbilinear(0);
1335
1336 switch (NameSelect.state) {
1337 case NAME_STATE_FADE_IN:
1338 fade = 0x80 - NameSelect.state_count * 6;
1339
1340 if (fade < 0) {
1341 fade = 0;
1342 }
1343
1344 if (NameSelect.chara_no != 0) {
1345 FrameImageDraw(0x80, fade);
1346 }
1347
1348 break;
1349 case NAME_STATE_EXIT:
1350 ExitNameEnterFunc();
1351 case NAME_STATE_FADE_OUT:
1352 fade = NameSelect.state_count * 3;
1353
1354 if (fade > 0x80) {
1355 fade = 0x80;
1356 }
1357
1358 AllFadeForMenu(fade);
1359 break;
1360 }
1361
1362 if (NameSelect.state != NAME_STATE_IDLE) {
1363 NameSelect.state_count++;
1364 }
1365
1366 setbilinear(1);
1367 }
1368}
1369
1377#ifdef PAL
1378s32 NameEnterKey() {
1379 int language;
1380 int chara_no;
1381 int cursor;
1382 int side_row;
1383 int name_pos;
1384 int action;
1385 int mes_no;
1386 int input_mode;
1387 int sound;
1388
1389 if (NameSelect.loaded == 0) {
1390 return 0;
1391 }
1392
1393 language = NameSelect.language;
1394 chara_no = NameSelect.chara_no;
1395
1396 switch (NameSelect.state) {
1397 case NAME_STATE_FADE_OUT:
1398 if (NameSelect.state_count >= 84) {
1399 GamePad.AutoRepeatOff();
1400 GamePad.MenuModeOff();
1401 NameSelect.state = NAME_STATE_EXIT;
1402 return 1;
1403 }
1404
1405 return 0;
1406 case NAME_STATE_TAB_FLASH:
1407 if (NameSelect.state_count > 8) {
1408 NameSelect.state = NAME_STATE_IDLE;
1409 }
1410
1411 break;
1412 }
1413
1414 cursor = NameSelect.cursor;
1415 side_row = NameSelect.side_row;
1416 name_pos = NameSelect.name_pos;
1417 action = NAME_ACTION_NONE;
1418 mes_no = -1;
1419
1420 switch (NameSelect.area) {
1421 case NAME_AREA_HELP:
1422 mes_no = chara_no + 100;
1423
1424 if (GamePad.Down(PAD_CROSS) || GamePad.Down(PAD_CIRCLE)) {
1425 NameSelect.area = NAME_AREA_TABS;
1426 NameSelect.state = NAME_STATE_IDLE;
1427 }
1428
1429 break;
1430 case NAME_AREA_CONFIRM:
1431 case NAME_AREA_EMPTY_NOTICE:
1432 if (NameSelect.area == NAME_AREA_CONFIRM) {
1433 mes_no = 91;
1434 }
1435
1436 if (NameSelect.area == NAME_AREA_EMPTY_NOTICE) {
1437 mes_no = 95;
1438 }
1439
1440 if (GamePad.Down(PAD_CROSS)) {
1441 NameSelect.state = NAME_STATE_IDLE;
1442 action = NAME_ACTION_FINISH;
1443 } else if (GamePad.Down(PAD_CIRCLE)) {
1444 NameSelect.area = NAME_AREA_KEYBOARD;
1445 NameSelect.state = NAME_STATE_IDLE;
1446 }
1447
1448 break;
1449 case NAME_AREA_KEYBOARD:
1450 if (NameSelect.input_mode > NAME_INPUT_HIRAGANA) {
1451 NameSelect.side_row = 0;
1452 }
1453
1454 switch (NameSelect.side_row) {
1455 case 0: {
1456 int keys_per_row = InputModeOrikaeshi[NameSelect.input_mode];
1457
1458 if (GamePad.Down(PAD_DOWN)) {
1459 int rows = 5;
1460
1461 switch (NameSelect.input_mode) {
1462 case NAME_INPUT_SYMBOL:
1463 rows -= 2;
1464 break;
1465 case NAME_INPUT_ALPHABET:
1466 rows = 4;
1467
1468 if (NameSelect.language > LANG_ENGLISH_UK) {
1469 rows = euro_code_linelimmit[NameSelect.language - 2] + 4;
1470 }
1471
1472 break;
1473 }
1474
1475 if (NameSelect.cursor / keys_per_row < rows) {
1476 NameSelect.cursor += keys_per_row;
1477 }
1478 } else if (GamePad.Down(PAD_LEFT)) {
1479 if (NameSelect.cursor % keys_per_row != 0) {
1480 NameSelect.cursor--;
1481 } else if (NameSelect.input_mode > NAME_INPUT_HIRAGANA) {
1482 NameSelect.cursor += keys_per_row - 1;
1483 } else {
1484 NameSelect.side_row = NameSelect.cursor / keys_per_row + 1;
1485 }
1486 } else if (GamePad.Down(PAD_RIGHT)) {
1487 if (keys_per_row - 1 != NameSelect.cursor % keys_per_row) {
1488 NameSelect.cursor++;
1489 } else if (NameSelect.input_mode > NAME_INPUT_HIRAGANA) {
1490 NameSelect.cursor -= keys_per_row - 1;
1491 } else {
1492 NameSelect.side_row = NameSelect.cursor / keys_per_row + 1;
1493 }
1494 } else if (GamePad.Down(PAD_UP)) {
1495 int row = NameSelect.cursor / keys_per_row;
1496
1497 if (0 < row) {
1498 NameSelect.cursor -= keys_per_row;
1499 } else if (row <= 0) {
1500 NameSelect.area = NAME_AREA_TABS;
1501
1502 if (NameSelect.cursor < 4) {
1503 NameSelect.cursor += 6;
1504 } else if (NameSelect.cursor >= 4 && NameSelect.cursor < 7) {
1505 NameSelect.cursor = NAME_TAB_HELP;
1506 } else {
1507 NameSelect.cursor = NAME_TAB_OK;
1508 }
1509 }
1510 }
1511
1512 break;
1513 }
1514 default: {
1515 int column = -1;
1516
1517 if (GamePad.Down(PAD_UP)) {
1518 if (NameSelect.side_row == 1) {
1519 NameSelect.side_row = 0;
1520 NameSelect.area = NAME_AREA_TABS;
1521 NameSelect.cursor = NAME_TAB_OK;
1522 } else {
1523 NameSelect.side_row--;
1524 }
1525 } else if (GamePad.Down(PAD_DOWN)) {
1526 if (NameSelect.side_row < 6) {
1527 NameSelect.side_row++;
1528 }
1529 } else if (GamePad.Down(PAD_LEFT)) {
1530 column = 1;
1531 } else if (GamePad.Down(PAD_RIGHT)) {
1532 column = 0;
1533 }
1534
1535 if (column != -1) {
1536 NameSelect.cursor = (NameSelect.side_row - 1) * 10 + column * 9;
1537 NameSelect.side_row = 0;
1538 }
1539
1540 break;
1541 }
1542 }
1543
1544 if (GamePad.Down(PAD_CROSS)) {
1545 action = NAME_ACTION_INPUT;
1546 } else if (GamePad.Down(PAD_CIRCLE)) {
1547 action = NAME_ACTION_BACKSPACE;
1548 }
1549
1550 break;
1551 case NAME_AREA_TABS: {
1552 if (GamePad.Down(PAD_UP)) {
1553 switch (language) {
1554 case LANG_JAPANESE:
1555 if (NameSelect.cursor >= NAME_TAB_LEFT) {
1556 if (NameSelect.cursor < NAME_TAB_DELETE) {
1557 NameSelect.cursor = NAME_TAB_KATAKANA;
1558 } else if (NameSelect.cursor < NAME_TAB_HELP) {
1559 NameSelect.cursor = NAME_TAB_HIRAGANA;
1560 } else if (NameSelect.cursor == NAME_TAB_HELP) {
1561 NameSelect.cursor = NAME_TAB_ALPHABET;
1562 }
1563 }
1564
1565 break;
1566 case LANG_ENGLISH_US:
1567 default:
1568 if (NameSelect.cursor >= NAME_TAB_LEFT) {
1569 if (NameSelect.cursor < NAME_TAB_HELP) {
1570 NameSelect.cursor = NAME_TAB_ALPHABET;
1571 } else if (NameSelect.cursor < 11) {
1572 NameSelect.cursor = NAME_TAB_SYMBOL;
1573 } else if (NameSelect.cursor == NAME_TAB_HELP) {
1574 NameSelect.cursor = NAME_TAB_DEFAULT_NAME;
1575 }
1576 }
1577
1578 break;
1579 }
1580 } else if (GamePad.Down(PAD_DOWN)) {
1581 if (NameSelect.cursor >= NAME_TAB_LEFT) {
1582 NameSelect.area = NAME_AREA_KEYBOARD;
1583 s8 below_key[7] = {0, 0, 1, 2, 3, 4, 4};
1584 NameSelect.cursor = below_key[NameSelect.cursor - NAME_TAB_LEFT];
1585 } else if (NameSelect.cursor < NAME_TAB_LEFT) {
1586 switch (language) {
1587 case LANG_JAPANESE:
1588 switch (NameSelect.cursor) {
1589 case NAME_TAB_KATAKANA:
1590 NameSelect.cursor = NAME_TAB_LEFT;
1591 break;
1592 case NAME_TAB_HIRAGANA:
1593 NameSelect.cursor = NAME_TAB_DELETE;
1594 break;
1595 case NAME_TAB_OK:
1596 NameSelect.cursor = 8;
1597 NameSelect.area = NAME_AREA_KEYBOARD;
1598 break;
1599 default:
1600 NameSelect.cursor = NAME_TAB_HELP;
1601 break;
1602 }
1603
1604 break;
1605 case LANG_ENGLISH_US:
1606 default:
1607 switch (NameSelect.cursor) {
1608 case NAME_TAB_ALPHABET:
1609 NameSelect.cursor = NAME_TAB_LEFT;
1610 break;
1611 case NAME_TAB_SYMBOL:
1612 NameSelect.cursor = NAME_TAB_INSERT;
1613 break;
1614 case NAME_TAB_OK:
1615 NameSelect.cursor = 8;
1616 NameSelect.area = NAME_AREA_KEYBOARD;
1617 break;
1618 default:
1619 NameSelect.cursor = NAME_TAB_HELP;
1620 break;
1621 }
1622
1623 break;
1624 }
1625 }
1626 }
1627
1628 static s8 up_or_down = 0;
1629
1630 if (GamePad.Down(PAD_LEFT)) {
1631 switch (language) {
1632 case LANG_JAPANESE:
1633 switch (NameSelect.cursor) {
1634 case NAME_TAB_KATAKANA:
1635 case NAME_TAB_LEFT:
1636 NameSelect.cursor = NAME_TAB_OK;
1637 break;
1638 case NAME_TAB_OK:
1639 if (up_or_down != 0) {
1640 NameSelect.cursor = NAME_TAB_DEFAULT_NAME;
1641 } else {
1642 NameSelect.cursor = NAME_TAB_HELP;
1643 }
1644
1645 break;
1646 default:
1647 NameSelect.cursor--;
1648 break;
1649 }
1650
1651 break;
1652 case LANG_ENGLISH_US:
1653 default:
1654 switch (NameSelect.cursor) {
1655 case NAME_TAB_ALPHABET:
1656 case NAME_TAB_LEFT:
1657 NameSelect.cursor = NAME_TAB_OK;
1658 break;
1659 case NAME_TAB_OK:
1660 if (up_or_down != 0) {
1661 NameSelect.cursor = NAME_TAB_DEFAULT_NAME;
1662 } else {
1663 NameSelect.cursor = NAME_TAB_HELP;
1664 }
1665
1666 break;
1667 default:
1668 NameSelect.cursor--;
1669 break;
1670 }
1671
1672 break;
1673 }
1674 } else if (GamePad.Down(PAD_RIGHT)) {
1675 switch (language) {
1676 case LANG_JAPANESE:
1677 switch (NameSelect.cursor) {
1678 case NAME_TAB_OK:
1679 if (up_or_down == 0) {
1680 NameSelect.cursor = NAME_TAB_KATAKANA;
1681 } else {
1682 NameSelect.cursor = NAME_TAB_LEFT;
1683 }
1684
1685 break;
1686 case NAME_TAB_HELP:
1687 NameSelect.cursor = NAME_TAB_OK;
1688 break;
1689 default:
1690 NameSelect.cursor++;
1691 break;
1692 }
1693
1694 break;
1695 case LANG_ENGLISH_US:
1696 default:
1697 switch (NameSelect.cursor) {
1698 case NAME_TAB_OK:
1699 if (up_or_down == 0) {
1700 NameSelect.cursor = NAME_TAB_ALPHABET;
1701 } else {
1702 NameSelect.cursor = NAME_TAB_LEFT;
1703 }
1704
1705 break;
1706 case NAME_TAB_HELP:
1707 NameSelect.cursor = NAME_TAB_OK;
1708 break;
1709 default:
1710 NameSelect.cursor++;
1711 break;
1712 }
1713
1714 break;
1715 }
1716 }
1717
1718 if (GamePad.Down(PAD_CIRCLE)) {
1719 action = NAME_ACTION_BACKSPACE;
1720 } else if (GamePad.Down(PAD_CROSS)) {
1721 NameSelect.pushed_tab = NameSelect.cursor;
1722
1723 if (NameSelect.cursor < NAME_TAB_DEFAULT_NAME) {
1724 if (NameSelect.input_mode != NameSelect.cursor) {
1725 NameSelect.input_mode = NameSelect.cursor;
1726 }
1727 } else {
1728 NameSelect.state = NAME_STATE_TAB_FLASH;
1729 NameSelect.state_count = 0;
1730 int tab_action[7] = {NAME_ACTION_DEFAULT_NAME, NAME_ACTION_DECIDE, NAME_ACTION_LEFT, NAME_ACTION_RIGHT, NAME_ACTION_DELETE, NAME_ACTION_INSERT, NAME_ACTION_HELP};
1731 action = tab_action[NameSelect.cursor - NAME_TAB_DEFAULT_NAME];
1732 }
1733 }
1734
1735 break;
1736 }
1737 }
1738
1739 if (GamePad.Down(PAD_START) && NameSelect.area < NAME_AREA_HELP) {
1740 action = NAME_ACTION_DECIDE;
1741 }
1742
1743 GamePad.Down(PAD_TRIANGLE);
1744
1745 if (GamePad.Down(PAD_L1)) {
1746 action = NAME_ACTION_LEFT;
1747 }
1748
1749 if (GamePad.Down(PAD_R1)) {
1750 action = NAME_ACTION_RIGHT;
1751 }
1752
1753 if (NameSelect.area < NAME_AREA_HELP) {
1754 if (GamePad.Down(PAD_R2)) {
1755 action = NAME_ACTION_NEXT_MODE;
1756 }
1757
1758 if (GamePad.Down(PAD_L2)) {
1759 action = NAME_ACTION_PREV_MODE;
1760 }
1761 }
1762
1763 input_mode = NameSelect.input_mode;
1764
1765 switch (action) {
1766 case NAME_ACTION_NONE:
1767 break;
1768 case NAME_ACTION_INPUT: {
1769 int slot;
1770 int code_base;
1771 int key;
1772 int code;
1773
1774 key = NameSelect.cursor;
1775 slot = NameSelect.name_pos;
1776
1777 switch (input_mode) {
1778 case NAME_INPUT_HIRAGANA:
1779 case NAME_INPUT_KATAKANA:
1780 if (input_mode == NAME_INPUT_HIRAGANA) {
1781 code_base = 82;
1782 } else {
1783 code_base = 1;
1784 }
1785
1786 if (NameSelect.side_row == 0) {
1787 int column = NameSelect.cursor % 10;
1788
1789 if (column < 5) {
1790 key = column + (NameSelect.cursor / 10) * 5;
1791 } else {
1792 key = column + 25 + (NameSelect.cursor / 10) * 5;
1793 }
1794
1795 if (key < 36) {
1796 code = key;
1797 } else {
1798 if (key >= 40 && key < 46) {
1799 code = key - 2;
1800 } else if (key >= 50 && key < 54) {
1801 code = key - 4;
1802 } else if (key >= 55 && key < 60) {
1803 code = key - 5;
1804 } else {
1805 switch (key) {
1806 case 49:
1807 key--;
1808 case 47:
1809 key--;
1810 case 45:
1811 case 39:
1812 key--;
1813 case 37:
1814 key--;
1815 break;
1816 default:
1817 key = 230 - code_base;
1818 break;
1819 }
1820
1821 code = key;
1822 }
1823 }
1824
1825 if (slot >= 10) {
1826 slot--;
1827 }
1828
1829 CharaName[slot] = code + code_base;
1830
1831 if (NameSelect.name_pos < 10) {
1832 NameSelect.name_pos++;
1833 }
1834 } else {
1835 switch (NameSelect.side_row) {
1836 case 1:
1837 if (0 < slot) {
1838 int previous_code = CharaName[slot - 1];
1839
1840 if ((previous_code >= 6 && previous_code < 21) || (previous_code >= 26 && previous_code < 31) || (previous_code >= 87 && previous_code < 102) || (previous_code >= 107 && previous_code < 112)) {
1841 CharaName[slot - 1] += 50;
1842 } else if (previous_code == 3) {
1843 CharaName[slot - 1] = 81;
1844 }
1845 }
1846
1847 break;
1848 case 2:
1849 if (0 < slot) {
1850 int previous_code = CharaName[slot - 1];
1851
1852 if ((previous_code >= 26 && previous_code < 31) || (previous_code >= 107 && previous_code < 112)) {
1853 CharaName[slot - 1] += 45;
1854 }
1855 }
1856
1857 break;
1858 case 3:
1859 key = 222 - code_base;
1860 code = key;
1861
1862 if (slot >= 10) {
1863 slot--;
1864 }
1865
1866 CharaName[slot] = code + code_base;
1867
1868 if (NameSelect.name_pos < 10) {
1869 NameSelect.name_pos++;
1870 }
1871
1872 break;
1873 default:
1874 CharaName[slot] = 230;
1875 break;
1876 }
1877 }
1878
1879 break;
1880 case NAME_INPUT_ALPHABET:
1881 if (NameSelect.cursor < 52) {
1882 code = NameSelect.cursor + 162;
1883 } else if (NameSelect.language > LANG_ENGLISH_UK) {
1884 code = menu_euro_codetbl[NameSelect.language - 2][0][NameSelect.cursor - 52];
1885 }
1886
1887 if (slot >= 10) {
1888 slot--;
1889 }
1890
1891 CharaName[slot] = code;
1892
1893 if (NameSelect.name_pos < 10) {
1894 NameSelect.name_pos++;
1895 }
1896
1897 break;
1898 case NAME_INPUT_SYMBOL:
1899 if (language == 0) {
1900 if (key < 28) {
1901 code = key;
1902 } else if (key >= 30 && key < 40) {
1903 code = key - 2;
1904 } else if (key == 28 || key == 29) {
1905 code = key + 10;
1906 } else {
1907 code = 16;
1908 }
1909
1910 if (slot >= 10) {
1911 slot--;
1912 }
1913
1914 CharaName[slot] = code + 214;
1915
1916 if (NameSelect.name_pos < 10) {
1917 NameSelect.name_pos++;
1918 }
1919 } else {
1920 if (language < 2) {
1921 int symbol = menu_kigoutbl[NameSelect.cursor];
1922
1923 code = symbol + 214;
1924
1925 if (symbol < 0) {
1926 code = 230;
1927 }
1928 } else {
1929 if (NameSelect.cursor < 40) {
1930 code = menu_kigoutbl[NameSelect.cursor] + 214;
1931 }
1932
1933 if (menu_kigoutbl[NameSelect.cursor] < 0) {
1934 code = 230;
1935 }
1936 }
1937
1938 if (slot >= 10) {
1939 slot--;
1940 }
1941
1942 CharaName[slot] = code;
1943
1944 if (NameSelect.name_pos < 10) {
1945 NameSelect.name_pos++;
1946 }
1947 }
1948
1949 printf("now Input CHaraID = %d\n", CharaName[slot]);
1950 break;
1951 }
1952
1953 break;
1954 }
1955 case NAME_ACTION_DELETE:
1956 for (int i = NameSelect.name_pos + 1; i <= 11; i++) {
1957 CharaName[i - 1] = CharaName[i];
1958 }
1959
1960 break;
1961 case NAME_ACTION_BACKSPACE:
1962 if (NameSelect.name_pos >= 10) {
1963 NameSelect.name_pos--;
1964 CharaName[NameSelect.name_pos] = 230;
1965 } else if (0 < NameSelect.name_pos) {
1966 CharaName[NameSelect.name_pos] = 230;
1967 NameSelect.name_pos--;
1968 } else {
1969 CharaName[0] = 230;
1970 }
1971
1972 break;
1973 case NAME_ACTION_INSERT: {
1974 int slot = NameSelect.name_pos;
1975 int i;
1976
1977 for (i = 9; i >= slot; i--) {
1978 CharaName[i + 1] = CharaName[i];
1979 }
1980
1981 CharaName[i + 1] = 230;
1982
1983 for (i = 10; i < 32; i++) {
1984 CharaName[i] = 230;
1985 }
1986
1987 break;
1988 }
1989 case NAME_ACTION_NEXT_MODE:
1990 switch (language) {
1991 case LANG_JAPANESE:
1992 if (input_mode < NAME_INPUT_SYMBOL) {
1993 NameSelect.input_mode = input_mode + 1;
1994 } else {
1995 NameSelect.input_mode = NAME_INPUT_KATAKANA;
1996 }
1997
1998 break;
1999 case LANG_ENGLISH_US:
2000 default:
2001 if (input_mode < NAME_INPUT_SYMBOL) {
2002 NameSelect.input_mode++;
2003 } else {
2004 NameSelect.input_mode = NAME_INPUT_ALPHABET;
2005 }
2006
2007 break;
2008 }
2009
2010 break;
2011 case NAME_ACTION_PREV_MODE:
2012 switch (language) {
2013 case LANG_JAPANESE:
2014 if (NAME_INPUT_KATAKANA < input_mode) {
2015 NameSelect.input_mode = input_mode - 1;
2016 } else {
2017 NameSelect.input_mode = NAME_INPUT_SYMBOL;
2018 }
2019
2020 break;
2021 case LANG_ENGLISH_US:
2022 default:
2023 if (input_mode > NAME_INPUT_ALPHABET) {
2024 NameSelect.input_mode--;
2025 } else {
2026 NameSelect.input_mode = NAME_INPUT_SYMBOL;
2027 }
2028
2029 break;
2030 }
2031
2032 break;
2033 case NAME_ACTION_LEFT:
2034 if (0 < NameSelect.name_pos) {
2035 if (NameSelect.name_pos >= 10) {
2036 NameSelect.name_pos--;
2037 }
2038
2039 NameSelect.name_pos--;
2040 }
2041
2042 break;
2043 case NAME_ACTION_RIGHT:
2044 if (NameSelect.name_pos < 10) {
2045 NameSelect.name_pos++;
2046 }
2047
2048 break;
2049 case NAME_ACTION_HELP:
2050 NameSelect.area = NAME_AREA_HELP;
2051 NameSelect.state = NAME_STATE_HELP;
2052 break;
2053 case NAME_ACTION_DEFAULT_NAME:
2054 NameDefaultSet(NameSelect.chara_no);
2055 break;
2056 case NAME_ACTION_DECIDE:
2057 switch (CheckName()) {
2058 case NAME_CHECK_OK: {
2059 int length;
2060 int i;
2061
2062 NameSelect.area = NAME_AREA_CONFIRM;
2063
2064 for (length = 10; length > 0; length--) {
2065 if (CharaName[length - 1] != 0 && CharaName[length - 1] != 230) {
2066 break;
2067 }
2068 }
2069
2070 for (i = 0; i < length; i++) {
2071 if (CharaName[i] == 0) {
2072 CharaName[i] = 230;
2073 }
2074 }
2075
2076 for (; length < 32; length++) {
2077 CharaName[length] = 0;
2078 }
2079
2080 break;
2081 }
2082 case NAME_CHECK_REJECTED:
2083 for (int i = 0; i < 10; i++) {
2084 CharaName[i] = 0;
2085 }
2086
2087 NameSelect.name_pos = 0;
2088 break;
2089 case NAME_CHECK_EMPTY:
2090 NameDefaultSet(NameSelect.chara_no);
2091 mes_no = 95;
2092 NameSelect.area = NAME_AREA_EMPTY_NOTICE;
2093 break;
2094 }
2095
2096 break;
2097 case NAME_ACTION_FINISH:
2098 for (int i = 0; i < 10; i++) {
2099 printf("CharaName[%d][%d] = %d\n", chara_no, i, CharaName[i]);
2100 }
2101
2102 GamePad.AutoRepeatOff();
2103 GamePad.MenuModeOff();
2104 NameSelect.area = NAME_AREA_KEYBOARD;
2105 NameSelect.state = NAME_STATE_FADE_OUT;
2106 NameSelect.state_count = 0;
2107 break;
2108 }
2109
2110 if (input_mode != NameSelect.input_mode && NameSelect.area != NAME_AREA_TABS) {
2111 int old_cursor;
2112 int row;
2113 int column;
2114
2115 switch (NameSelect.input_mode) {
2116 case NAME_INPUT_HIRAGANA:
2117 case NAME_INPUT_SYMBOL:
2118 if (input_mode == NAME_INPUT_ALPHABET) {
2119 old_cursor = NameSelect.cursor;
2120 row = old_cursor / 13;
2121 column = old_cursor % 13;
2122
2123 if (NameSelect.input_mode == NAME_INPUT_HIRAGANA && column == 12) {
2124 NameSelect.side_row = row + 1;
2125 } else {
2126 if (column >= 5) {
2127 column--;
2128 }
2129
2130 if (NameSelect.input_mode == NAME_INPUT_SYMBOL) {
2131 while (column >= 10) {
2132 column--;
2133 }
2134
2135 if (NameSelect.language > LANG_JAPANESE) {
2136 while (row >= 4) {
2137 row--;
2138 }
2139 }
2140 }
2141
2142 NameSelect.cursor = column + row * 10;
2143 }
2144 }
2145
2146 break;
2147 case NAME_INPUT_ALPHABET: {
2148 old_cursor = NameSelect.cursor;
2149 row = old_cursor / 10;
2150 column = old_cursor % 10;
2151
2152 if (NameSelect.side_row > 0) {
2153 NameSelect.cursor = NameSelect.side_row * 13 - 1;
2154 } else {
2155 if (column >= 5) {
2156 column++;
2157 }
2158
2159 if (row >= 4) {
2160 row = 4;
2161 }
2162
2163 NameSelect.cursor = column + row * 13;
2164 }
2165
2166 break;
2167 }
2168 }
2169 }
2170
2171 s8 rows;
2172
2173 switch (NameSelect.input_mode) {
2174 case NAME_INPUT_HIRAGANA:
2175 case NAME_INPUT_KATAKANA:
2176 break;
2177 case NAME_INPUT_SYMBOL:
2178 rows = 3;
2179
2180 while (NameSelect.cursor >= 40) {
2181 NameSelect.cursor -= 10;
2182 }
2183
2184 break;
2185 case NAME_INPUT_ALPHABET:
2186 rows = 4;
2187
2188 if (NameSelect.language > LANG_ENGLISH_UK) {
2189 rows += euro_code_linelimmit[NameSelect.language - 2];
2190 }
2191
2192 while (NameSelect.cursor >= rows * 13) {
2193 NameSelect.cursor -= 13;
2194 }
2195
2196 break;
2197 }
2198
2199 sound = -1;
2200
2201 if (cursor != NameSelect.cursor || side_row != NameSelect.side_row) {
2202 sound = MENU_SOUND_CURSOR;
2203 }
2204
2205 if (name_pos != NameSelect.name_pos || input_mode != NameSelect.input_mode) {
2206 sound = MENU_SOUND_CONFIRM;
2207 }
2208
2209 if (GamePad.Down(PAD_CROSS)) {
2210 sound = MENU_SOUND_CONFIRM;
2211 }
2212
2213 if (GamePad.Down(PAD_CIRCLE) || action == NAME_ACTION_DELETE || action == NAME_ACTION_BACKSPACE) {
2214 sound = MENU_SOUND_REFUSE;
2215 }
2216
2217 if (CommonMenuMes3.mes_made != 0) {
2218 CommonMenuMes3.MakeMesWin(0);
2219 }
2220
2221 if (CommonMenuMes2.mes_made != mes_no) {
2222 CommonMenuMes2.MakeMesWin(mes_no);
2223 }
2224
2225 ComMenuSePlay(sound);
2226 return 0;
2227}
2228#else
2229s32 NameEnterKey() {
2230 int language;
2231 int chara_no;
2232 int cursor;
2233 int side_row;
2234 int name_pos;
2235 int action;
2236 int mes_no;
2237 int input_mode;
2238 int sound;
2239
2240 if (NameSelect.loaded == 0) {
2241 return 0;
2242 }
2243
2244 language = NameSelect.language;
2245 chara_no = NameSelect.chara_no;
2246
2247 switch (NameSelect.state) {
2248 case NAME_STATE_FADE_OUT:
2249 if (NameSelect.state_count >= 84) {
2250 GamePad.AutoRepeatOff();
2251 GamePad.MenuModeOff();
2252 NameSelect.state = NAME_STATE_EXIT;
2253 return 1;
2254 }
2255
2256 return 0;
2257 case NAME_STATE_TAB_FLASH:
2258 if (NameSelect.state_count > 8) {
2259 NameSelect.state = NAME_STATE_IDLE;
2260 }
2261
2262 break;
2263 }
2264
2265 cursor = NameSelect.cursor;
2266 side_row = NameSelect.side_row;
2267 name_pos = NameSelect.name_pos;
2268 action = NAME_ACTION_NONE;
2269 mes_no = -1;
2270
2271 switch (NameSelect.area) {
2272 case NAME_AREA_HELP:
2273 mes_no = chara_no + 100;
2274
2275 if (GamePad.Down(PAD_CROSS) || GamePad.Down(PAD_CIRCLE)) {
2276 NameSelect.area = NAME_AREA_TABS;
2277 NameSelect.state = NAME_STATE_IDLE;
2278 }
2279
2280 break;
2281 case NAME_AREA_CONFIRM:
2282 case NAME_AREA_EMPTY_NOTICE:
2283 if (NameSelect.area == NAME_AREA_CONFIRM) {
2284 mes_no = 91;
2285 }
2286
2287 if (NameSelect.area == NAME_AREA_EMPTY_NOTICE) {
2288 mes_no = 95;
2289 }
2290
2291 if (GamePad.Down(PAD_CROSS)) {
2292 NameSelect.state = NAME_STATE_IDLE;
2293 action = NAME_ACTION_FINISH;
2294 } else if (GamePad.Down(PAD_CIRCLE)) {
2295 NameSelect.area = NAME_AREA_KEYBOARD;
2296 NameSelect.state = NAME_STATE_IDLE;
2297 }
2298
2299 break;
2300 case NAME_AREA_KEYBOARD:
2301 if (NameSelect.input_mode > NAME_INPUT_HIRAGANA) {
2302 NameSelect.side_row = 0;
2303 }
2304
2305 switch (NameSelect.side_row) {
2306 case 0: {
2307 int keys_per_row = InputModeOrikaeshi[NameSelect.input_mode];
2308
2309 if (GamePad.Down(PAD_DOWN)) {
2310 int rows = 5;
2311
2312 switch (NameSelect.input_mode) {
2313 case NAME_INPUT_SYMBOL:
2314 rows -= 2;
2315 case NAME_INPUT_ALPHABET:
2316 rows -= 1;
2317 break;
2318 }
2319
2320 if (NameSelect.cursor / keys_per_row < rows) {
2321 NameSelect.cursor += keys_per_row;
2322 }
2323 } else if (GamePad.Down(PAD_LEFT)) {
2324 if (NameSelect.cursor % keys_per_row != 0) {
2325 NameSelect.cursor--;
2326 } else if (NameSelect.input_mode > NAME_INPUT_HIRAGANA) {
2327 NameSelect.cursor += keys_per_row - 1;
2328 } else {
2329 NameSelect.side_row = NameSelect.cursor / keys_per_row + 1;
2330 }
2331 } else if (GamePad.Down(PAD_RIGHT)) {
2332 if (keys_per_row - 1 != NameSelect.cursor % keys_per_row) {
2333 NameSelect.cursor++;
2334 } else if (NameSelect.input_mode > NAME_INPUT_HIRAGANA) {
2335 NameSelect.cursor -= keys_per_row - 1;
2336 } else {
2337 NameSelect.side_row = NameSelect.cursor / keys_per_row + 1;
2338 }
2339 } else if (GamePad.Down(PAD_UP)) {
2340 int row = NameSelect.cursor / keys_per_row;
2341
2342 if (0 < row) {
2343 NameSelect.cursor -= keys_per_row;
2344 } else if (row <= 0) {
2345 NameSelect.area = NAME_AREA_TABS;
2346
2347 if (NameSelect.cursor < 4) {
2348 NameSelect.cursor += 6;
2349 } else if (NameSelect.cursor >= 4 && NameSelect.cursor < 7) {
2350 NameSelect.cursor = NAME_TAB_HELP;
2351 } else {
2352 NameSelect.cursor = NAME_TAB_OK;
2353 }
2354 }
2355 }
2356
2357 break;
2358 }
2359 default: {
2360 int column = -1;
2361
2362 if (GamePad.Down(PAD_UP)) {
2363 if (NameSelect.side_row == 1) {
2364 NameSelect.side_row = 0;
2365 NameSelect.area = NAME_AREA_TABS;
2366 NameSelect.cursor = NAME_TAB_OK;
2367 } else {
2368 NameSelect.side_row--;
2369 }
2370 } else if (GamePad.Down(PAD_DOWN)) {
2371 if (NameSelect.side_row < 6) {
2372 NameSelect.side_row++;
2373 }
2374 } else if (GamePad.Down(PAD_LEFT)) {
2375 column = 1;
2376 } else if (GamePad.Down(PAD_RIGHT)) {
2377 column = 0;
2378 }
2379
2380 if (column != -1) {
2381 NameSelect.cursor = (NameSelect.side_row - 1) * 10 + column * 9;
2382 NameSelect.side_row = 0;
2383 }
2384
2385 break;
2386 }
2387 }
2388
2389 if (GamePad.Down(PAD_CROSS)) {
2390 action = NAME_ACTION_INPUT;
2391 } else if (GamePad.Down(PAD_CIRCLE)) {
2392 action = NAME_ACTION_BACKSPACE;
2393 }
2394
2395 break;
2396 case NAME_AREA_TABS: {
2397 int tab_first_key[3] = {0, 2, 2};
2398
2399 if (GamePad.Down(PAD_UP)) {
2400 switch (language) {
2401 case LANG_JAPANESE:
2402 if (NameSelect.cursor >= NAME_TAB_LEFT) {
2403 if (NameSelect.cursor < NAME_TAB_DELETE) {
2404 NameSelect.cursor = NAME_TAB_KATAKANA;
2405 } else if (NameSelect.cursor < NAME_TAB_HELP) {
2406 NameSelect.cursor = NAME_TAB_HIRAGANA;
2407 } else if (NameSelect.cursor == NAME_TAB_HELP) {
2408 NameSelect.cursor = NAME_TAB_ALPHABET;
2409 }
2410 }
2411
2412 break;
2413 case LANG_ENGLISH_US:
2414 default:
2415 if (NameSelect.cursor >= NAME_TAB_LEFT) {
2416 if (NameSelect.cursor < NAME_TAB_HELP) {
2417 NameSelect.cursor = NAME_TAB_ALPHABET;
2418 } else if (NameSelect.cursor < 11) {
2419 NameSelect.cursor = NAME_TAB_SYMBOL;
2420 } else if (NameSelect.cursor == NAME_TAB_HELP) {
2421 NameSelect.cursor = NAME_TAB_DEFAULT_NAME;
2422 }
2423 }
2424
2425 break;
2426 }
2427 } else if (GamePad.Down(PAD_DOWN)) {
2428 if (NameSelect.cursor >= NAME_TAB_LEFT) {
2429 NameSelect.area = NAME_AREA_KEYBOARD;
2430
2431 switch (NameSelect.cursor) {
2432 case NAME_TAB_LEFT:
2433 case NAME_TAB_RIGHT:
2434 NameSelect.cursor = 0;
2435 break;
2436 case NAME_TAB_DELETE:
2437 NameSelect.cursor = 1;
2438 break;
2439 case NAME_TAB_INSERT:
2440 NameSelect.cursor = 3;
2441 break;
2442 case NAME_TAB_HELP:
2443 NameSelect.cursor = 4;
2444 break;
2445 }
2446 } else if (NameSelect.cursor < NAME_TAB_LEFT) {
2447 switch (language) {
2448 case LANG_JAPANESE:
2449 switch (NameSelect.cursor) {
2450 case NAME_TAB_KATAKANA:
2451 NameSelect.cursor = NAME_TAB_LEFT;
2452 break;
2453 case NAME_TAB_HIRAGANA:
2454 NameSelect.cursor = NAME_TAB_DELETE;
2455 break;
2456 case NAME_TAB_OK:
2457 NameSelect.cursor = 8;
2458 NameSelect.area = NAME_AREA_KEYBOARD;
2459 break;
2460 default:
2461 NameSelect.cursor = NAME_TAB_HELP;
2462 break;
2463 }
2464
2465 break;
2466 case LANG_ENGLISH_US:
2467 default:
2468 switch (NameSelect.cursor) {
2469 case NAME_TAB_ALPHABET:
2470 NameSelect.cursor = NAME_TAB_LEFT;
2471 break;
2472 case NAME_TAB_SYMBOL:
2473 NameSelect.cursor = NAME_TAB_HELP;
2474 break;
2475 case NAME_TAB_OK:
2476 NameSelect.cursor = 8;
2477 NameSelect.area = NAME_AREA_KEYBOARD;
2478 break;
2479 default:
2480 NameSelect.cursor = NAME_TAB_HELP;
2481 break;
2482 }
2483
2484 break;
2485 }
2486 }
2487 }
2488
2489 static s8 up_or_down = 0;
2490
2491 if (GamePad.Down(PAD_LEFT)) {
2492 switch (language) {
2493 case LANG_JAPANESE:
2494 switch (NameSelect.cursor) {
2495 case NAME_TAB_KATAKANA:
2496 case NAME_TAB_LEFT:
2497 NameSelect.cursor = NAME_TAB_OK;
2498 break;
2499 case NAME_TAB_OK:
2500 if (up_or_down != 0) {
2501 NameSelect.cursor = NAME_TAB_DEFAULT_NAME;
2502 } else {
2503 NameSelect.cursor = NAME_TAB_HELP;
2504 }
2505
2506 break;
2507 default:
2508 NameSelect.cursor--;
2509 break;
2510 }
2511
2512 break;
2513 case LANG_ENGLISH_US:
2514 default:
2515 switch (NameSelect.cursor) {
2516 case NAME_TAB_ALPHABET:
2517 case NAME_TAB_LEFT:
2518 NameSelect.cursor = NAME_TAB_OK;
2519 break;
2520 case NAME_TAB_OK:
2521 if (up_or_down != 0) {
2522 NameSelect.cursor = NAME_TAB_DEFAULT_NAME;
2523 } else {
2524 NameSelect.cursor = NAME_TAB_HELP;
2525 }
2526
2527 break;
2528 default:
2529 NameSelect.cursor--;
2530 break;
2531 }
2532
2533 break;
2534 }
2535 } else if (GamePad.Down(PAD_RIGHT)) {
2536 switch (language) {
2537 case LANG_JAPANESE:
2538 switch (NameSelect.cursor) {
2539 case NAME_TAB_OK:
2540 if (up_or_down == 0) {
2541 NameSelect.cursor = NAME_TAB_KATAKANA;
2542 } else {
2543 NameSelect.cursor = NAME_TAB_LEFT;
2544 }
2545
2546 break;
2547 case NAME_TAB_HELP:
2548 NameSelect.cursor = NAME_TAB_OK;
2549 break;
2550 default:
2551 NameSelect.cursor++;
2552 break;
2553 }
2554
2555 break;
2556 case LANG_ENGLISH_US:
2557 default:
2558 switch (NameSelect.cursor) {
2559 case NAME_TAB_OK:
2560 if (up_or_down == 0) {
2561 NameSelect.cursor = NAME_TAB_ALPHABET;
2562 } else {
2563 NameSelect.cursor = NAME_TAB_LEFT;
2564 }
2565
2566 break;
2567 case NAME_TAB_HELP:
2568 NameSelect.cursor = NAME_TAB_OK;
2569 break;
2570 default:
2571 NameSelect.cursor++;
2572 break;
2573 }
2574
2575 break;
2576 }
2577 }
2578
2579 if (GamePad.Down(PAD_CIRCLE)) {
2580 action = NAME_ACTION_BACKSPACE;
2581 } else if (GamePad.Down(PAD_CROSS)) {
2582 NameSelect.pushed_tab = NameSelect.cursor;
2583
2584 if (NameSelect.cursor < NAME_TAB_DEFAULT_NAME) {
2585 if (NameSelect.input_mode != NameSelect.cursor) {
2586 NameSelect.input_mode = NameSelect.cursor;
2587 }
2588 } else {
2589 NameSelect.state = NAME_STATE_TAB_FLASH;
2590 NameSelect.state_count = 0;
2591 int tab_action[7] = {NAME_ACTION_DEFAULT_NAME, NAME_ACTION_DECIDE, NAME_ACTION_LEFT, NAME_ACTION_RIGHT, NAME_ACTION_DELETE, NAME_ACTION_INSERT, NAME_ACTION_HELP};
2592 action = tab_action[NameSelect.cursor - NAME_TAB_DEFAULT_NAME];
2593 }
2594 }
2595
2596 break;
2597 }
2598 }
2599
2600 if (GamePad.Down(PAD_START) && NameSelect.area < NAME_AREA_HELP) {
2601 action = NAME_ACTION_DECIDE;
2602 }
2603
2604 GamePad.Down(PAD_TRIANGLE);
2605
2606 if (GamePad.Down(PAD_L1)) {
2607 action = NAME_ACTION_LEFT;
2608 }
2609
2610 if (GamePad.Down(PAD_R1)) {
2611 action = NAME_ACTION_RIGHT;
2612 }
2613
2614 if (NameSelect.area < NAME_AREA_HELP) {
2615 if (GamePad.Down(PAD_R2)) {
2616 action = NAME_ACTION_NEXT_MODE;
2617 }
2618
2619 if (GamePad.Down(PAD_L2)) {
2620 action = NAME_ACTION_PREV_MODE;
2621 }
2622 }
2623
2624 input_mode = NameSelect.input_mode;
2625
2626 switch (action) {
2627 case NAME_ACTION_NONE:
2628 break;
2629 case NAME_ACTION_INPUT: {
2630 int slot;
2631 int code_base;
2632 int key;
2633 int raw_key;
2634
2635 key = NameSelect.cursor;
2636 slot = NameSelect.name_pos;
2637
2638 switch (input_mode) {
2639 case NAME_INPUT_HIRAGANA:
2640 case NAME_INPUT_KATAKANA:
2641 if (input_mode == NAME_INPUT_HIRAGANA) {
2642 code_base = 82;
2643 } else {
2644 code_base = 1;
2645 }
2646
2647 if (NameSelect.side_row == 0) {
2648 int column = key % 10;
2649
2650 if (column < 5) {
2651 key = column + (key / 10) * 5;
2652 } else {
2653 key = column + 25 + (key / 10) * 5;
2654 }
2655
2656 if (key < 36) {
2657 raw_key = key;
2658 } else {
2659 if (key >= 40 && key < 46) {
2660 key -= 2;
2661 } else if (key >= 50 && key < 54) {
2662 key -= 4;
2663 } else if (key >= 55 && key < 60) {
2664 key -= 5;
2665 } else {
2666 switch (key) {
2667 case 49:
2668 key--;
2669 case 47:
2670 key--;
2671 case 45:
2672 case 39:
2673 key--;
2674 case 37:
2675 key--;
2676 break;
2677 default:
2678 key = 230 - code_base;
2679 break;
2680 }
2681 }
2682 }
2683
2684 if (slot >= 10) {
2685 slot--;
2686 }
2687
2688 CharaName[slot] = key + code_base;
2689
2690 if (NameSelect.name_pos < 10) {
2691 NameSelect.name_pos++;
2692 }
2693 } else {
2694 switch (NameSelect.side_row) {
2695 case 1:
2696 if (0 < slot) {
2697 int previous_code = CharaName[slot - 1];
2698
2699 if ((previous_code >= 6 && previous_code < 21) || (previous_code >= 26 && previous_code < 31) || (previous_code >= 87 && previous_code < 102) || (previous_code >= 107 && previous_code < 112)) {
2700 CharaName[slot - 1] += 50;
2701 } else if (previous_code == 3) {
2702 CharaName[slot - 1] = 81;
2703 }
2704 }
2705
2706 break;
2707 case 2:
2708 if (0 < slot) {
2709 int previous_code = CharaName[slot - 1];
2710
2711 if ((previous_code >= 26 && previous_code < 31) || (previous_code >= 107 && previous_code < 112)) {
2712 CharaName[slot - 1] += 45;
2713 }
2714 }
2715
2716 break;
2717 case 3:
2718 key = 222 - code_base;
2719
2720 if (slot >= 10) {
2721 slot--;
2722 }
2723
2724 CharaName[slot] = key + code_base;
2725
2726 if (NameSelect.name_pos < 10) {
2727 NameSelect.name_pos++;
2728 }
2729
2730 break;
2731 default:
2732 CharaName[slot] = 230;
2733 break;
2734 }
2735 }
2736
2737 break;
2738 case NAME_INPUT_ALPHABET:
2739 key = (key < 52) ? key : ((key < 62) ? key + 28 : 68);
2740
2741 if (slot >= 10) {
2742 slot--;
2743 }
2744
2745 CharaName[slot] = key + 162;
2746
2747 if (NameSelect.name_pos < 10) {
2748 NameSelect.name_pos++;
2749 }
2750
2751 break;
2752 case NAME_INPUT_SYMBOL:
2753 if (key < 12) {
2754 raw_key = key;
2755 } else {
2756 if (key > 11 && key < 15) {
2757 key += 1;
2758 } else if (key >= 15 && key < 20) {
2759 key += 2;
2760 } else if (key >= 20 && key < 25) {
2761 key += 21;
2762 } else {
2763 key = 16;
2764 }
2765 }
2766
2767 if (slot >= 10) {
2768 slot--;
2769 }
2770
2771 CharaName[slot] = key + 214;
2772
2773 if (NameSelect.name_pos < 10) {
2774 NameSelect.name_pos++;
2775 }
2776
2777 printf("now Input CHaraID = %d\n", CharaName[slot]);
2778 break;
2779 }
2780
2781 break;
2782 }
2783 case NAME_ACTION_TOGGLE_VOICING: {
2784 int slot = NameSelect.name_pos;
2785 int old_code;
2786
2787 if (slot <= 0) {
2788 slot = 0;
2789 }
2790
2791 old_code = CharaName[slot];
2792
2793 if ((old_code >= 36 && old_code < 39) || (old_code >= 117 && old_code < 120)) {
2794 CharaName[slot] += 11;
2795 } else if ((old_code >= 47 && old_code < 50) || (old_code >= 128 && old_code < 131)) {
2796 CharaName[slot] -= 11;
2797 }
2798
2799 if (old_code == 18) {
2800 CharaName[slot] = 50;
2801 } else if (old_code == 50) {
2802 CharaName[slot] = 68;
2803 } else if (old_code == 68) {
2804 CharaName[slot] = 18;
2805 } else if ((old_code >= 6 && old_code < 21) || (old_code >= 26 && old_code < 31) || (old_code >= 87 && old_code < 102) || (old_code >= 107 && old_code < 112)) {
2806 CharaName[slot] += 50;
2807 } else if ((old_code >= 56 && old_code < 71) || (old_code >= 76 && old_code < 81) || (old_code >= 137 && old_code < 152) || (old_code >= 157 && old_code < 162)) {
2808 CharaName[slot] -= 50;
2809 }
2810
2811 if (old_code >= 162 && old_code < 188) {
2812 CharaName[slot] += 26;
2813 } else if (old_code >= 188 && old_code < 214) {
2814 CharaName[slot] -= 26;
2815 }
2816
2817 break;
2818 }
2819 case NAME_ACTION_DELETE:
2820 for (int i = NameSelect.name_pos + 1; i <= 11; i++) {
2821 CharaName[i - 1] = CharaName[i];
2822 }
2823
2824 break;
2825 case NAME_ACTION_BACKSPACE:
2826 if (NameSelect.name_pos >= 10) {
2827 NameSelect.name_pos--;
2828 CharaName[NameSelect.name_pos] = 230;
2829 } else if (0 < NameSelect.name_pos) {
2830 CharaName[NameSelect.name_pos] = 230;
2831 NameSelect.name_pos--;
2832 } else {
2833 CharaName[0] = 230;
2834 }
2835
2836 break;
2837 case NAME_ACTION_INSERT: {
2838 int slot = NameSelect.name_pos;
2839 int i;
2840
2841 for (i = 9; i >= slot; i--) {
2842 CharaName[i + 1] = CharaName[i];
2843 }
2844
2845 CharaName[i + 1] = 230;
2846
2847 for (i = 10; i < 32; i++) {
2848 CharaName[i] = 230;
2849 }
2850
2851 break;
2852 }
2853 case NAME_ACTION_NEXT_MODE:
2854 switch (language) {
2855 case LANG_JAPANESE:
2856 if (input_mode < NAME_INPUT_SYMBOL) {
2857 NameSelect.input_mode = input_mode + 1;
2858 } else {
2859 NameSelect.input_mode = NAME_INPUT_KATAKANA;
2860 }
2861
2862 break;
2863 case LANG_ENGLISH_US:
2864 default:
2865 if (input_mode < NAME_INPUT_SYMBOL) {
2866 NameSelect.input_mode++;
2867 } else {
2868 NameSelect.input_mode = NAME_INPUT_ALPHABET;
2869 }
2870
2871 break;
2872 }
2873
2874 break;
2875 case NAME_ACTION_PREV_MODE:
2876 switch (language) {
2877 case LANG_JAPANESE:
2878 if (NAME_INPUT_KATAKANA < input_mode) {
2879 NameSelect.input_mode = input_mode - 1;
2880 } else {
2881 NameSelect.input_mode = NAME_INPUT_SYMBOL;
2882 }
2883
2884 break;
2885 case LANG_ENGLISH_US:
2886 default:
2887 if (input_mode > NAME_INPUT_ALPHABET) {
2888 NameSelect.input_mode--;
2889 } else {
2890 NameSelect.input_mode = NAME_INPUT_SYMBOL;
2891 }
2892
2893 break;
2894 }
2895
2896 break;
2897 case NAME_ACTION_LEFT:
2898 if (0 < NameSelect.name_pos) {
2899 if (NameSelect.name_pos >= 10) {
2900 NameSelect.name_pos--;
2901 }
2902
2903 NameSelect.name_pos--;
2904 }
2905
2906 break;
2907 case NAME_ACTION_RIGHT:
2908 if (NameSelect.name_pos < 10) {
2909 NameSelect.name_pos++;
2910 }
2911
2912 break;
2913 case NAME_ACTION_HELP:
2914 NameSelect.area = NAME_AREA_HELP;
2915 NameSelect.state = NAME_STATE_HELP;
2916 break;
2917 case NAME_ACTION_DEFAULT_NAME:
2918 NameDefaultSet(NameSelect.chara_no);
2919 break;
2920 case NAME_ACTION_DECIDE:
2921 switch (CheckName()) {
2922 case NAME_CHECK_OK: {
2923 int length;
2924 int i;
2925
2926 NameSelect.area = NAME_AREA_CONFIRM;
2927
2928 for (length = 10; length > 0; length--) {
2929 if (CharaName[length - 1] != 0 && CharaName[length - 1] != 230) {
2930 break;
2931 }
2932 }
2933
2934 for (i = 0; i < length; i++) {
2935 if (CharaName[i] == 0) {
2936 CharaName[i] = 230;
2937 }
2938 }
2939
2940 for (; length < 32; length++) {
2941 CharaName[length] = 0;
2942 }
2943
2944 break;
2945 }
2946 case NAME_CHECK_REJECTED:
2947 for (int i = 0; i < 10; i++) {
2948 CharaName[i] = 0;
2949 }
2950
2951 NameSelect.name_pos = 0;
2952 break;
2953 case NAME_CHECK_EMPTY:
2954 NameDefaultSet(NameSelect.chara_no);
2955 mes_no = 95;
2956 NameSelect.area = NAME_AREA_EMPTY_NOTICE;
2957 break;
2958 }
2959
2960 break;
2961 case NAME_ACTION_FINISH:
2962 for (int i = 0; i < 10; i++) {
2963 printf("CharaName[%d][%d] = %d\n", chara_no, i, CharaName[i]);
2964 }
2965
2966 GamePad.AutoRepeatOff();
2967 GamePad.MenuModeOff();
2968 NameSelect.area = NAME_AREA_KEYBOARD;
2969 NameSelect.state = NAME_STATE_FADE_OUT;
2970 NameSelect.state_count = 0;
2971 break;
2972 }
2973
2974 if (input_mode != NameSelect.input_mode && NameSelect.area != NAME_AREA_TABS) {
2975 int old_cursor;
2976 int row;
2977 int column;
2978
2979 switch (NameSelect.input_mode) {
2980 case NAME_INPUT_HIRAGANA:
2981 case NAME_INPUT_SYMBOL:
2982 if (input_mode == NAME_INPUT_ALPHABET) {
2983 old_cursor = NameSelect.cursor;
2984 row = old_cursor / 13;
2985 column = old_cursor % 13;
2986
2987 if (NameSelect.input_mode == NAME_INPUT_HIRAGANA && column == 12) {
2988 NameSelect.side_row = row + 1;
2989 } else {
2990 if (column >= 5) {
2991 column--;
2992 }
2993
2994 if (NameSelect.input_mode == NAME_INPUT_SYMBOL) {
2995 while (column >= 10) {
2996 column--;
2997 }
2998
2999 if (NameSelect.language > LANG_JAPANESE) {
3000 while (row >= 3) {
3001 row--;
3002 }
3003 }
3004 }
3005
3006 NameSelect.cursor = column + row * 10;
3007 }
3008 }
3009
3010 break;
3011 case NAME_INPUT_ALPHABET: {
3012 old_cursor = NameSelect.cursor;
3013 row = old_cursor / 10;
3014 column = old_cursor % 10;
3015
3016 if (NameSelect.side_row > 0) {
3017 NameSelect.cursor = NameSelect.side_row * 13 - 1;
3018 } else {
3019 if (column >= 5) {
3020 column++;
3021 }
3022
3023 if (row >= 4) {
3024 row = 4;
3025 }
3026
3027 NameSelect.cursor = column + row * 13;
3028 }
3029
3030 break;
3031 }
3032 }
3033 }
3034
3035 if (NameSelect.input_mode == NAME_INPUT_SYMBOL) {
3036 while (NameSelect.cursor >= 40) {
3037 NameSelect.cursor -= 10;
3038 }
3039 }
3040
3041 if (NameSelect.input_mode == NAME_INPUT_ALPHABET) {
3042 while (NameSelect.cursor >= 66) {
3043 NameSelect.cursor -= 13;
3044 }
3045 }
3046
3047 sound = -1;
3048
3049 if (cursor != NameSelect.cursor || side_row != NameSelect.side_row) {
3050 sound = MENU_SOUND_CURSOR;
3051 }
3052
3053 if (name_pos != NameSelect.name_pos || input_mode != NameSelect.input_mode) {
3054 sound = MENU_SOUND_CONFIRM;
3055 }
3056
3057 if (GamePad.Down(PAD_CROSS)) {
3058 sound = MENU_SOUND_CONFIRM;
3059 }
3060
3061 if (GamePad.Down(PAD_CIRCLE) || action == NAME_ACTION_DELETE || action == NAME_ACTION_BACKSPACE) {
3062 sound = MENU_SOUND_REFUSE;
3063 }
3064
3065 if (CommonMenuMes3.mes_made != 0) {
3066 CommonMenuMes3.MakeMesWin(0);
3067 }
3068
3069 if (CommonMenuMes2.mes_made != mes_no) {
3070 CommonMenuMes2.MakeMesWin(mes_no);
3071 }
3072
3073 ComMenuSePlay(sound);
3074 return 0;
3075}
3076#endif
3077
3085void NameDefaultSet(int chara_no) {
3086 int language = GetMenuLangFlag();
3087 s16 default_names[7][6][11] = {
3088 {{20, 1, 46}, {12, 47, 5}, {60, 43, 222}, {41, 77, 222}, {3, 46, 56, 56}, {5, 63, 35, 46, 70} },
3089 {{181, 202, 188, 201}, {185, 196, 188, 202}, {168, 202, 205, 202}, {179, 208, 189, 212}, {182, 201, 194, 188, 194, 188}, {176, 206, 200, 202, 201, 191}},
3090 {{181, 202, 188, 201}, {185, 196, 188, 202}, {168, 202, 205, 202}, {179, 208, 189, 212}, {182, 201, 194, 188, 194, 188}, {176, 206, 200, 202, 201, 191}},
3091 {{181, 202, 188, 201}, {185, 196, 188, 202}, {168, 202, 205, 202}, {179, 208, 189, 212}, {182, 201, 194, 188, 194, 188}, {176, 206, 200, 202, 201, 191}},
3092 {{181, 202, 188, 201}, {185, 196, 188, 202}, {168, 202, 205, 202}, {179, 208, 189, 212}, {182, 201, 194, 188, 194, 188}, {176, 206, 200, 202, 201, 191}},
3093 {{181, 202, 188, 201}, {185, 196, 188, 202}, {168, 202, 205, 202}, {179, 208, 189, 212}, {182, 201, 194, 188, 194, 188}, {176, 206, 200, 202, 201, 191}},
3094 {{181, 202, 188, 201}, {185, 196, 188, 202}, {168, 202, 205, 202}, {179, 208, 189, 212}, {182, 201, 194, 188, 194, 188}, {176, 206, 200, 202, 201, 191}},
3095 };
3096 s16 *name = SaveData->GetCharaName(chara_no);
3097 int length;
3098
3099 for (length = 0; default_names[language][chara_no][length] != 0 && length < 10; length++) {
3100 name[length] = default_names[language][chara_no][length];
3101 }
3102
3103 NameSelect.name_pos = length;
3104
3105 for (; length < 32; length++) {
3106 name[length] = 0;
3107 }
3108}
3109
3110// clang-format off
3112#ifdef PAL
3113s8 AlphabetEtcOffset[163][2] = {
3114 {1, 0}, {0, 1}, {1, 1}, {0, 1}, {1, 0}, {2, 2}, {0, 1}, {1, 2},
3115 {2, 4}, {4, 4}, {2, 2}, {0, 2}, {0, 1}, {0, 2}, {2, 2}, {1, 1},
3116 {0, 0}, {1, 1}, {1, 1}, {0, 0}, {2, 1}, {0, 2}, {0, 0}, {0, 2},
3117 {2, 2}, {1, 2}, {2, 1}, {1, 2}, {1, 1}, {2, 1}, {2, 2}, {2, 2},
3118 {1, 1}, {1, 3}, {3, 3}, {4, 2}, {1, 3}, {2, 4}, {0, 0}, {1, 1},
3119 {2, 1}, {1, 2}, {2, 1}, {1, 3}, {1, 2}, {1, 1}, {1, 1}, {1, 1},
3120 {1, 1}, {1, 2}, {1, 2}, {1, 1}, {0, 8}, {1, 1}, {-1, 4}, {3, 4},
3121 {2, 2}, {1, 0}, {0, 1}, {1, 0}, {1, 1}, {1, 2}, {0, 1}, {0, 0},
3122 {0, 1}, {6, 0}, {-4, 7}, {0, 0}, {0, 0}, {1, 1}, {1, 0}, {0, 1},
3123 {3, 2}, {2, 3}, {4, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 3}, {3, 4},
3124 {1, 2}, {4, 6}, {1, 2}, {2, 2}, {1, 2}, {2, 1}, {2, 2}, {3, 1},
3125 {1, 1}, {1, 2}, {4, 6}, {2, 8}, {2, 8}, {2, 2}, {1, 3}, {1, 4},
3126 {1, 2}, {0, 0}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1},
3127 {1, 1}, {1, 1}, {1, 1}, {1, 1}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
3128 {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {1, 1}, {1, 1},
3129 {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1},
3130 {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1},
3131 {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1},
3132 {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1},
3133 {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {2, 2},
3134 {1, 1}, {1, 1}, {1, 1},
3135};
3136#else
3137s8 AlphabetEtcOffset[97][2] = {
3138 {1, 0}, {0, 1}, {1, 1}, {0, 1}, {1, 0}, {2, 2}, {0, 1}, {1, 2},
3139 {2, 4}, {4, 4}, {2, 2}, {0, 2}, {0, 1}, {0, 2}, {2, 2}, {1, 1},
3140 {0, 0}, {1, 1}, {1, 1}, {0, 0}, {2, 1}, {0, 2}, {0, 0}, {0, 2},
3141 {2, 2}, {1, 2}, {2, 1}, {1, 2}, {1, 1}, {2, 1}, {2, 2}, {2, 2},
3142 {1, 1}, {1, 3}, {3, 3}, {4, 2}, {1, 3}, {2, 4}, {0, 0}, {1, 1},
3143 {2, 1}, {1, 2}, {2, 1}, {1, 3}, {1, 2}, {1, 1}, {1, 1}, {1, 1},
3144 {1, 1}, {1, 2}, {1, 2}, {1, 1}, {0, 8}, {1, 1}, {-1, 4}, {3, 4},
3145 {2, 2}, {1, 0}, {0, 1}, {1, 0}, {1, 1}, {1, 2}, {0, 1}, {0, 0},
3146 {0, 1}, {6, 0}, {-4, 7}, {0, 0}, {0, 0}, {1, 1}, {1, 0}, {0, 1},
3147 {3, 2}, {2, 3}, {4, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 3}, {3, 4},
3148 {1, 2}, {4, 6}, {1, 2}, {2, 2}, {1, 2}, {2, 1}, {2, 2}, {3, 1},
3149 {1, 1}, {1, 2}, {4, 6}, {2, 8}, {2, 8}, {2, 2}, {1, 3}, {1, 4},
3150 {1, 2},
3151};
3152#endif
3153// clang-format on
3154
3162static int GetFontLRTumeW(int position, int left_code, int char_code) {
3163 int kerning = 0;
3164
3165 if (char_code >= 0xA2 && char_code < 0x100) {
3166 kerning += AlphabetEtcOffset[char_code - 0xA2][0];
3167 }
3168
3169 if (position - 1 >= 0 && char_code >= 0xA2 && char_code < 0x100) {
3170 kerning += AlphabetEtcOffset[char_code - 0xA2][1];
3171 }
3172
3173 return kerning;
3174}
3175
3183void CharaSelectNameDraw2(int x, int y, short *name, CTexture **textures, int blend_mode) {
3184 if (name == NULL) {
3185 return;
3186 }
3187
3188 int condensed;
3189 int draw_x;
3190#ifdef PAL
3191 CTexture *texture;
3192#endif
3193 int last;
3194
3195 last = 9;
3196
3197 while (name[last] == 0 && last > 0) {
3198 last--;
3199 }
3200
3201 condensed = 0;
3202 int width = (last + 1) * 0x16;
3203
3204 if (width >= 0xB0) {
3205 condensed = 1;
3206 }
3207
3208 int kerning = 0;
3209
3210 for (int slot = last; slot >= 0; slot--) {
3211 kerning += GetFontLRTumeW(slot, name[slot - 1], name[slot]);
3212 }
3213
3214 if (condensed) {
3215 width -= kerning;
3216 }
3217
3218 draw_x = x + 0x44 + (width >> 1) - ((width / (last + 1)) >> 1);
3219
3220 for (; last >= 0; last--) {
3221 int cell_x;
3222 int cell_y;
3223#ifdef PAL
3224 texture = GetNameTextureInfo(textures, name[last], cell_x, cell_y);
3225#else
3226 CTexture *texture = GetNameTextureInfo(textures, name[last], cell_x, cell_y);
3227#endif
3228 CRect_i_ cell_rect(cell_x, cell_y, 0x16, 0x17);
3229
3230#ifdef PAL
3231 if (texture != NULL) {
3232 DrawMenu2DSprite(texture, CRect_i_(draw_x + 2, y + 2, 0x16, 0x15), cell_rect, 10, 10, 10, blend_mode);
3233 DrawMenu2DSprite(texture, CRect_i_(draw_x, y, 0x16, 0x15), cell_rect, blend_mode);
3234 }
3235#else
3236 DrawMenu2DSprite(texture, CRect_i_(draw_x + 2, y + 2, 0x16, 0x15), cell_rect, 10, 10, 10, blend_mode);
3237 DrawMenu2DSprite(texture, CRect_i_(draw_x, y, 0x16, 0x15), cell_rect, blend_mode);
3238#endif
3239
3240 int kerning_step = 0;
3241
3242 if (last >= 0 && condensed == 1) {
3243 kerning_step = GetFontLRTumeW(last, name[last - 1], name[last]);
3244 }
3245
3246 draw_x -= 0x14 - kerning_step;
3247 }
3248}
3249
3257void DrawSaveBoardCharaName2(int x, int y, s16 *name, CTexture **textures, spRGBA top_color, spRGBA bottom_color) {
3258 spRGBA shadow_top = {10, 10, 10, top_color.a};
3259 spRGBA shadow_bottom = {10, 10, 10, bottom_color.a};
3260 int condensed;
3261 int draw_x;
3262 CTexture *texture;
3263 int last;
3264
3265 last = 9;
3266
3267 while (name[last] == 0 && last > 0) {
3268 last--;
3269 }
3270
3271 condensed = 0;
3272 int width = (last + 1) * 0x16;
3273
3274 if (width >= 0xB0) {
3275 condensed = 1;
3276 }
3277
3278 int kerning = 0;
3279
3280 for (int slot = last; slot >= 0; slot--) {
3281 kerning += GetFontLRTumeW(slot, name[slot - 1], name[slot]);
3282 }
3283
3284 if (condensed == 1) {
3285 width -= kerning;
3286 }
3287
3288 draw_x = x + 0x36 + (width >> 1) - ((width / (last + 1)) >> 1);
3289
3290 for (; last >= 0; last--) {
3291 int cell_x;
3292 int cell_y;
3293 texture = GetNameTextureInfo(textures, name[last], cell_x, cell_y);
3294 CRect_i_ cell_rect(cell_x, cell_y, 0x16, 0x17);
3295
3296 DrawMenu2DSprite(texture, CRect_i_(draw_x + 2, y + 2, 0x16, 0x15), cell_rect, &shadow_top, &shadow_top, &shadow_bottom, &shadow_bottom);
3297 DrawMenu2DSprite(texture, CRect_i_(draw_x, y, 0x16, 0x15), cell_rect, &top_color, &top_color, &bottom_color, &bottom_color);
3298
3299 int kerning_step = 0;
3300
3301 if (last >= 0 && condensed == 1) {
3302 kerning_step = GetFontLRTumeW(last, name[last - 1], name[last]);
3303 }
3304
3305 draw_x -= 0x14 - kerning_step;
3306 }
3307}
3308
3316int GetMsgLengthCharaName(int chara_no) {
3317 if (chara_no < 0 || chara_no > 5) {
3318 return 0;
3319 }
3320
3321 s16 *name = SaveData->GetCharaName(chara_no);
3322 int length = 0;
3323
3324 while (*name != 0 && length < 10) {
3325 name++;
3326 length++;
3327 }
3328
3329 return length;
3330}
3331
3333OPENING_BOOK OpenBook;
3334
3336u_long128 *OpeningReadBuf;
3337
3345void InitOpeningBook(u_long128 *buffer, int *tex_blocks) {
3346 u_long128 *load_buffer = buffer;
3347
3348 if (load_buffer == NULL) {
3349 load_buffer = (u_long128 *) read_buffer;
3350 }
3351
3352 load_buffer = MenuCalcBufAlignment(load_buffer);
3353 StartReadBG();
3354 LoadFileBGMenuData("openbook.pak", load_buffer);
3355 OpenBook.tex_block = tex_blocks[0];
3356 OpenBook.name_tex_block = tex_blocks[1];
3357 OpenBook.open = false;
3358 OpenBook.step = OPENING_BOOK_LOAD;
3359 OpenBook.page = 0;
3360 OpenBook.fade = 128;
3361 OpenBook.text_alpha = 0;
3362}
3363
3371int OpeningBookKey() {
3372 int result;
3373
3374 ReadBG();
3375 result = 0;
3376
3377 switch (OpenBook.step) {
3378 case OPENING_BOOK_LOAD:
3379 if (OpenBook.open == 0 && ReadBGSync() == 0) {
3380 LOADTEXTURE_INFO2 info[3] = {
3381 {"#frame_image#640#" SCREEN_HEIGHT_STR "#4", 0, 0},
3382 {NULL, 0, 0},
3383 {NULL, 0, 0}
3384 };
3385
3386 info[0].block_no = OpenBook.tex_block;
3387 info[1].block_no = OpenBook.tex_block;
3388 BG_READ_INFO *read_file = GetReadBGFile(0);
3389 info[1].name = (char *) GetPackFile((u_int *) read_file->buffer, "opentex.img", NULL);
3390 TexManager.DeleteTextureBlock(OpenBook.tex_block);
3391 TexManager.CleanUpTextureList();
3392 TexManager.LoadTextureBlockEX(-1, info);
3393 OpeningReadBuf = read_file->buffer + (read_file->size >> 4) + 1;
3394 OpeningReadBuf = MenuCalcBufAlignment(OpeningReadBuf);
3395 short *messages = (short *) GetPackFile((u_int *) read_file->buffer, "opmes.bin", NULL);
3396
3397 CommonMenuMes2.text_columns = MES_WIN_COLUMNS;
3398 CommonMenuMes2.text_rows = 10;
3399 CommonMenuMes2.text_len = 0;
3400 CommonMenuMes2.text_width = 0;
3401 CommonMenuMes2.text_height = 0;
3402 CommonMenuMes2.fade = 0.0f;
3403 CommonMenuMes2.fade_in = true;
3404 CommonMenuMes2.text_rate = CommonMenuMes2.text_rate_set;
3405 CommonMenuMes2.waiting = false;
3406 CommonMenuMes2.text_at = 0.0f;
3407 CommonMenuMes2.text_no = 0;
3408 CommonMenuMes2.text_from = 0;
3409 CommonMenuMes2.page_from = 0;
3410 CommonMenuMes2.InitMesWinTbl();
3411 CommonMenuMes2.clut_now = CommonMenuMes2.clut_default;
3412 CommonMenuMes2.wait = 0;
3413 CommonMenuMes2.blink = 0;
3414 CommonMenuMes2.auto_page_wait = 0;
3415 CommonMenuMes2.mes_made = -1;
3416 CommonMenuMes2.edge_alpha = 0x80;
3417
3418 for (int i = 0; i < 10; i++) {
3419 CommonMenuMes2.mes_no[i] = -1;
3420 }
3421
3422 for (int i = 0; i < 8; i++) {
3423 CommonMenuMes2.values[i] = 0;
3424 }
3425
3426 CommonMenuMes2.value = 0;
3427 CommonMenuMes2.value_signed = false;
3428 CommonMenuMes2.value_show = true;
3429 CommonMenuMes2.value_narrow = false;
3430 CommonMenuMes2.space_width = -1;
3431 CommonMenuMes2.space_area = -1;
3432 CommonMenuMes2.cursor_row = -1;
3433 CommonMenuMes2.cursor_y = 0;
3434 CommonMenuMes2.cursor_lit = false;
3435
3436 for (int i = 0; i < 10; i++) {
3437 CommonMenuMes2.line_pos[i].x = -1;
3438 CommonMenuMes2.line_pos[i].y = -1;
3439 }
3440
3441 CommonMenuMes2.SetMesFukidashi(MES_FUKIDASHI_LARGE_TABLE_EDGE);
3442 CommonMenuMes2.text_rate = 0.0f;
3443 CommonMenuMes2.text_rate_set = 0.0f;
3444 CommonMenuMes2.page_arrow = true;
3445 CommonMenuMes2.centre_rows = true;
3446 CommonMenuMes2.columns = 40;
3447 CommonMenuMes2.rows = 3;
3448 int language = GetMenuLangFlag();
3449
3450 if (language > LANG_JAPANESE) {
3451 CommonMenuMes2.char_width--;
3452 }
3453
3454 CommonMenuMes2.tex_block = 0x1A;
3455 CommonMenuMes2.tex_buff = MesWinTexBuff_02;
3456 CommonMenuMes2.SetBuff(messages);
3457 CommonMenuMes2.edge_alpha = OpenBook.text_alpha;
3458 OpenBook.open = true;
3459 OpenBook.fade = 0x80;
3460 s8 page_text_y[7] = {20, 16, 16, 16, 16, 16, 16};
3461 CommonMenuMes2.text_y = page_text_y[language] + 300;
3462 CommonMenuMes2.mes_made = -1;
3463 CommonMenuMes2.MakeMesWin(100);
3464 }
3465
3466 if (OpenBook.open != 0) {
3467 OpenBook.fade--;
3468
3469 if (OpenBook.fade <= 0) {
3470 OpenBook.fade = 0;
3471 }
3472 }
3473
3474 if (OpenBook.fade <= 0) {
3475 OpenBook.step = OPENING_BOOK_TEXT_IN;
3476 OpenBook.text_alpha = 0;
3477 }
3478
3479 break;
3480 case OPENING_BOOK_TEXT_IN:
3481 OpenBook.text_alpha += 2;
3482
3483 if (OpenBook.text_alpha >= 0x80) {
3484 OpenBook.text_alpha = 0x80;
3485 OpenBook.step = OPENING_BOOK_WAIT;
3486 OpenBook.fade = 0;
3487 }
3488
3489 break;
3490 case OPENING_BOOK_TEXT_OUT:
3491 OpenBook.text_alpha -= 2;
3492
3493 if (OpenBook.text_alpha <= 0) {
3494 OpenBook.text_alpha = 0;
3495 OpenBook.page++;
3496 CommonMenuMes2.MakeMesWin(OpenBook.page + 100);
3497 OpenBook.step = OPENING_BOOK_TEXT_IN;
3498 }
3499
3500 break;
3501 case OPENING_BOOK_WAIT:
3502 if (GamePad.Down(PAD_CROSS)) {
3503 OpenBook.step = OPENING_BOOK_TEXT_OUT;
3504
3505 if (OpenBook.page >= 11) {
3506 OpenBook.step = OPENING_BOOK_FINISH;
3507 }
3508 }
3509
3510#ifdef PAL
3511 if (DebugMode && GamePad.Down2(PAD_CROSS)) {
3512 OpenBook.step = OPENING_BOOK_FINISH;
3513 }
3514
3515#endif
3516 break;
3517 case OPENING_BOOK_FINISH:
3518 OpenBook.text_alpha--;
3519
3520 if (OpenBook.text_alpha <= 0 && OpenBook.step == OPENING_BOOK_FINISH && OpenBook.text_alpha <= 0) {
3521 CommonMenuMes2.page_arrow = false;
3522 InitNameRegist(0, OpenBook.name_tex_block, OpeningReadBuf);
3523 OpenBook.step = OPENING_BOOK_NAME_ENTRY;
3524 }
3525
3526 break;
3527 case OPENING_BOOK_NAME_ENTRY:
3528 result = NameEnterKey();
3529 break;
3530 }
3531
3532 return result;
3533}
3534
3542void OpeningBookDraw() {
3543 setbilinear(0);
3544 AllFadeForMenu(0x80);
3545
3546 if (OpenBook.open == 0) {
3547 return;
3548 }
3549
3550 MenuTextureReload(OpenBook.tex_block);
3551 DrawFullSizePicture(TexManager.GetTexture("openbook", -1), 0, 0, 0x80);
3552
3553 switch (OpenBook.step) {
3554 case OPENING_BOOK_LOAD:
3555 case OPENING_BOOK_TEXT_IN:
3556 case OPENING_BOOK_WAIT:
3557 case OPENING_BOOK_TEXT_OUT:
3558 case OPENING_BOOK_FINISH:
3559 MenuTextureReload(CommonMenuMes2.tex_block);
3560 CommonMenuMes2.edge_alpha = OpenBook.text_alpha;
3561 GetMenuCommonPutXY(&CommonMenuMes2, 0x14C - CommonMenuMes2.char_width);
3562 CommonMenuMes2.Step();
3563 CommonMenuMes2.DrawMesWin();
3564 AllFadeForMenu(OpenBook.fade);
3565 break;
3566 case OPENING_BOOK_NAME_ENTRY:
3567 case OPENING_BOOK_UNK_6:
3568 NameEnterDraw();
3569 break;
3570 }
3571}
int Down2(int mask)
Definition gamepad.cpp:601
int Down(int mask)
Definition gamepad.cpp:583
void MenuModeOff()
Definition gamepad.cpp:617
void MenuModeOn(int threshold)
Definition gamepad.cpp:613
void SetAutoRepeat(int mask, int initial_delay, int repeat_delay)
Definition gamepad.cpp:485
void AutoRepeatOff()
Definition gamepad.cpp:609
s16 * GetCharaName(int chara_no)
Definition savedata.cpp:41
s32 text_rows
Definition clsmes.hpp:158
s32 text_y
Definition clsmes.hpp:152
s32 text_from
Definition clsmes.hpp:198
s32 cursor_y
Definition clsmes.hpp:225
s32 text_x
Definition clsmes.hpp:151
float text_rate_set
Definition clsmes.hpp:193
void DrawMesWin()
Definition clsmes.cpp:2619
s32 wait
Definition clsmes.hpp:204
s32 text_no
Definition clsmes.hpp:197
s32 char_height
Definition clsmes.hpp:154
void Step()
Definition clsmes.cpp:575
s32 mes_no[10]
Definition clsmes.hpp:216
s32 page_from
Definition clsmes.hpp:199
s32 page_arrow
Definition clsmes.hpp:209
int GetMesLen_system(int mes_no)
Definition clsmes.cpp:1089
s32 text_height
Definition clsmes.hpp:161
s32 text_width
Definition clsmes.hpp:160
s32 char_width
Definition clsmes.hpp:153
s32 text_columns
Definition clsmes.hpp:157
s32 text_len
Definition clsmes.hpp:159
s32 value
Definition clsmes.hpp:218
void InitMesWinTbl()
Definition clsmes.cpp:1265
s32 waiting
Definition clsmes.hpp:194
s32 cursor_lit
Definition clsmes.hpp:226
s32 auto_page_wait
Definition clsmes.hpp:206
s32 centre_rows
Definition clsmes.hpp:211
s32 fade_in
Definition clsmes.hpp:188
s32 space_width
Definition clsmes.hpp:222
s32 clut_now
Definition clsmes.hpp:203
s32 blink
Definition clsmes.hpp:205
void * tex_buff
Definition clsmes.hpp:233
s32 cursor_row
Definition clsmes.hpp:224
float fade
Definition clsmes.hpp:187
void SetBuff(short *buff)
Definition clsmes.cpp:456
s32 columns
Definition clsmes.hpp:155
s32 mes_made
Definition clsmes.hpp:207
s32 values[8]
Definition clsmes.hpp:217
s32 value_narrow
Definition clsmes.hpp:221
s32 tex_block
Definition clsmes.hpp:227
s32 value_signed
Definition clsmes.hpp:219
void SetMesFukidashi(int style)
Definition clsmes.cpp:511
float text_rate
Definition clsmes.hpp:192
s32 stay_frame
Definition clsmes.hpp:189
s32 edge_alpha
Definition clsmes.hpp:213
s32 clut_default
Definition clsmes.hpp:202
MES_LINE_POS line_pos[10]
Definition clsmes.hpp:228
int MakeMesWin(int mes_no)
Definition clsmes.cpp:1669
s32 value_show
Definition clsmes.hpp:220
s32 rows
Definition clsmes.hpp:156
s32 space_area
Definition clsmes.hpp:223
float text_at
Definition clsmes.hpp:196
u_long128 * buffer
Definition dataread.hpp:29
u8 a
Definition rect.hpp:49