9#include "background_run_setup_gfx.h"
26#define CHANGE_DECK_BTN_MAIN_COLOR_PAL_IDX 1
27#define RED_BTN_MAIN_COLOR_PAL_IDX 10
28#define RED_DISABLED_BTN_MAIN_COLOR_PAL_IDX 11
29#define BLUE_BTN_MAIN_COLOR_PAL_IDX 12
30#define BLUE_DISABLED_BTN_MAIN_COLOR_PAL_IDX 13
31#define BACK_BTN_MAIN_COLOR_PAL_IDX 14
33#define NEW_RUN_BTN_OUTLINE_COLOR_PAL_IDX 30
34#define RESUME_BTN_OUTLINE_COLOR_PAL_IDX 31
35#define CHANGE_DECK_BTN_OUTLINE_COLOR_PAL_IDX 32
36#define SEED_CHECK_BTN_OUTLINE_COLOR_PAL_IDX 33
37#define SEED_DECK_BTN_OUTLINE_COLOR_PAL_IDX 34
38#define PLAY_BTN_OUTLINE_COLOR_PAL_IDX 35
39#define BACK_BTN_OUTLINE_COLOR_PAL_IDX 36
41#define KEYBOARD_1_BTN_OUTLINE_COLOR_PAL_IDX 40
42#define KEYBOARD_2_BTN_OUTLINE_COLOR_PAL_IDX 41
43#define KEYBOARD_3_BTN_OUTLINE_COLOR_PAL_IDX 42
44#define KEYBOARD_4_BTN_OUTLINE_COLOR_PAL_IDX 43
45#define KEYBOARD_5_BTN_OUTLINE_COLOR_PAL_IDX 44
46#define KEYBOARD_6_BTN_OUTLINE_COLOR_PAL_IDX 45
47#define KEYBOARD_7_BTN_OUTLINE_COLOR_PAL_IDX 46
48#define KEYBOARD_8_BTN_OUTLINE_COLOR_PAL_IDX 47
49#define KEYBOARD_9_BTN_OUTLINE_COLOR_PAL_IDX 48
50#define KEYBOARD_0_BTN_OUTLINE_COLOR_PAL_IDX 49
52#define KEYBOARD_A_BTN_OUTLINE_COLOR_PAL_IDX 50
53#define KEYBOARD_B_BTN_OUTLINE_COLOR_PAL_IDX 51
54#define KEYBOARD_C_BTN_OUTLINE_COLOR_PAL_IDX 52
55#define KEYBOARD_D_BTN_OUTLINE_COLOR_PAL_IDX 53
56#define KEYBOARD_E_BTN_OUTLINE_COLOR_PAL_IDX 54
57#define KEYBOARD_F_BTN_OUTLINE_COLOR_PAL_IDX 55
58#define KEYBOARD_G_BTN_OUTLINE_COLOR_PAL_IDX 56
59#define KEYBOARD_H_BTN_OUTLINE_COLOR_PAL_IDX 57
60#define KEYBOARD_I_BTN_OUTLINE_COLOR_PAL_IDX 58
61#define KEYBOARD_J_BTN_OUTLINE_COLOR_PAL_IDX 59
63#define KEYBOARD_K_BTN_OUTLINE_COLOR_PAL_IDX 60
64#define KEYBOARD_L_BTN_OUTLINE_COLOR_PAL_IDX 61
65#define KEYBOARD_M_BTN_OUTLINE_COLOR_PAL_IDX 62
66#define KEYBOARD_N_BTN_OUTLINE_COLOR_PAL_IDX 63
67#define KEYBOARD_O_BTN_OUTLINE_COLOR_PAL_IDX 64
68#define KEYBOARD_P_BTN_OUTLINE_COLOR_PAL_IDX 65
69#define KEYBOARD_Q_BTN_OUTLINE_COLOR_PAL_IDX 66
70#define KEYBOARD_R_BTN_OUTLINE_COLOR_PAL_IDX 67
71#define KEYBOARD_S_BTN_OUTLINE_COLOR_PAL_IDX 68
72#define KEYBOARD_T_BTN_OUTLINE_COLOR_PAL_IDX 69
74#define KEYBOARD_RAND_BTN_OUTLINE_COLOR_PAL_IDX 70
75#define KEYBOARD_U_BTN_OUTLINE_COLOR_PAL_IDX 71
76#define KEYBOARD_V_BTN_OUTLINE_COLOR_PAL_IDX 72
77#define KEYBOARD_W_BTN_OUTLINE_COLOR_PAL_IDX 73
78#define KEYBOARD_X_BTN_OUTLINE_COLOR_PAL_IDX 74
79#define KEYBOARD_Y_BTN_OUTLINE_COLOR_PAL_IDX 75
80#define KEYBOARD_Z_BTN_OUTLINE_COLOR_PAL_IDX 76
81#define KEYBOARD_DEL_BTN_OUTLINE_COLOR_PAL_IDX 77
85 RUN_SETUP_SUBSTATE_CHOOSE_DECK,
86 RUN_SETUP_SUBSTATE_CHOOSE_SEED,
87 RUN_SETUP_SUBSTATE_RESUME,
88 RUN_SETUP_SUBSTATE_MAX
102 [RUN_SETUP_SUBSTATE_CHOOSE_DECK] = STATE_INFO_INIT_UPDATE_FN(
106 [RUN_SETUP_SUBSTATE_CHOOSE_SEED] = STATE_INFO_INIT_UPDATE_FN(
110 [RUN_SETUP_SUBSTATE_RESUME] = STATE_INFO_INIT_UPDATE_FN(
119 .num_infos = RUN_SETUP_SUBSTATE_MAX,
132static const BG_POINT RUN_SETUP_FRAME_BG_SE_FILL_SRC_POS = {9 , 31};
134static const Rect RUN_SETUP_CHOOSE_DECK_CHOICE_BG_9_PTCH_DEST = {6 , 4 , 23, 13};
135static const NinePatchRect RUN_SETUP_CHOOSE_DECK_CHOICE_BG_9_PTCH_SRC = {
140static const Rect RUN_SETUP_CHOOSE_DECK_CLEAN_LEFT_DEST = {4 , 6 , 5 , 13};
141static const Rect RUN_SETUP_CHOOSE_DECK_CLEAN_RIGHT_DEST = {24, 6 ,25 , 13};
143static const Rect RUN_SETUP_CHOOSE_DECK_USE_SEED_BTN_OFF_SRC = {30, 8 , 31, 10};
144static const Rect RUN_SETUP_CHOOSE_DECK_USE_SEED_BTN_ON_SRC = {30, 11, 31, 13};
145static const BG_POINT RUN_SETUP_CHOOSE_DECK_USE_SEED_BTN_DEST_POS = {17, 14};
147static const BG_POINT RUN_SETUP_CHOOSE_DECK_SEED_BTN_3X3_SRC_POS = {0 , 29};
148static const BG_POINT RUN_SETUP_CHOOSE_DECK_SEED_BTN_DISABLED_3X3_SRC_POS = {3 , 29};
149static const Rect RUN_SETUP_CHOOSE_DECK_SEED_BTN_DEST = {19, 14, 24, 16};
151static const Rect RUN_SETUP_CHOOSE_SEED_FRAME_CLEAN_DEST = {4 , 3 , 25, 5 };
152static const Rect RUN_SETUP_CHOOSE_SEED_KEYBOARD_SRC = {10, 24, 31, 31};
153static const Rect RUN_SETUP_CHOOSE_SEED_FIELD_SRC = {24, 22, 31, 23};
154static const BG_POINT RUN_SETUP_CHOOSE_SEED_KEYBOARD_DEST_POS = {4 , 6};
155static const BG_POINT RUN_SETUP_CHOOSE_SEED_FIELD_DEST_POS = {11, 4};
157static const BG_POINT RUN_SETUP_CHOOSE_SEED_DECK_BTN_3X3_SRC_POS = RUN_SETUP_CHOOSE_DECK_SEED_BTN_3X3_SRC_POS;
158static const Rect RUN_SETUP_CHOOSE_SEED_DECK_BTN_DEST = {17, 14, 24, 16};
161#define RUN_SETUP_DECK_SPRITE_T_X 48
162#define RUN_SETUP_DECK_SPRITE_T_Y 54
163static const BG_POINT RUN_SETUP_DECK_NAME_TEXT_POS = {80 , 40 };
164static const BG_POINT RUN_SETUP_DECK_DESC_TEXT_POS = {80 , 56 };
165static const Rect RUN_SETUP_DECK_NAME_DESC_RECT = {80 , 40 ,176, 96 };
166static const BG_POINT RUN_SETUP_SEED_FIELD_TEXT_POS = {96 , 40 };
167static const BG_POINT RUN_SETUP_SEED_DECK_TEXT_POS = {152, 120};
168static const BG_POINT RUN_SETUP_PLAY_TEXT_POS = {76 , 120};
169static const BG_POINT RUN_SETUP_BACK_TEXT_POS = {104, 136};
174#pragma region TAB BAR
184 RUN_SETUP_TAB_NEW_RUN,
185 RUN_SETUP_TAB_RESUME,
189static bool is_saved_game_valid =
false;
195static Button tabs_buttons[RUN_SETUP_TAB_MAX] = {
196 {NEW_RUN_BTN_OUTLINE_COLOR_PAL_IDX, RED_BTN_MAIN_COLOR_PAL_IDX, NULL, NULL},
197 {RESUME_BTN_OUTLINE_COLOR_PAL_IDX, RED_BTN_MAIN_COLOR_PAL_IDX, NULL, NULL},
203#pragma region BOTTOM BUTTONS
219static void back_row_on_key_transit(
SelectionGrid* selection_grid, Selection* selection);
229static Button back_button = {
230 BACK_BTN_OUTLINE_COLOR_PAL_IDX, BACK_BTN_MAIN_COLOR_PAL_IDX,
237#pragma region CHOOSE DECK
244 RUN_SETUP_DECK_ROW_CHANGE_DECK,
245 RUN_SETUP_DECK_ROW_SEED_PLAY,
246 RUN_SETUP_DECK_ROW_BACK,
247 RUN_SETUP_DECK_ROW_MAX
250enum RunSetupDeckBottomButtons
252 RUN_SETUP_DECK_BB_PLAY,
253 RUN_SETUP_DECK_BB_USE_SEED,
254 RUN_SETUP_DECK_BB_SEED,
255 RUN_SETUP_DECK_BB_MAX
264 const Selection* prev_selection,
265 const Selection* new_selection
273 RUN_SETUP_DECK_ROW_CHANGE_DECK,
279 RUN_SETUP_DECK_ROW_SEED_PLAY,
285 RUN_SETUP_DECK_ROW_BACK,
288 back_row_on_key_transit,
294static const Selection RUN_SETUP_CHOOSE_DECK_INIT_SEL = {0, 0};
295static const Selection RUN_SETUP_CHOOSE_DECK_SEL_FROM_SEED = {2, 1};
299 RUN_SETUP_DECK_ROW_MAX,
300 RUN_SETUP_CHOOSE_DECK_INIT_SEL
307static Button change_deck_button = {
308 CHANGE_DECK_BTN_OUTLINE_COLOR_PAL_IDX,
309 CHANGE_DECK_BTN_MAIN_COLOR_PAL_IDX,
316static Button choose_deck_bottom_buttons[RUN_SETUP_DECK_BB_MAX] = {
318 PLAY_BTN_OUTLINE_COLOR_PAL_IDX, BLUE_BTN_MAIN_COLOR_PAL_IDX,
321 SEED_CHECK_BTN_OUTLINE_COLOR_PAL_IDX, RED_BTN_MAIN_COLOR_PAL_IDX,
324 SEED_DECK_BTN_OUTLINE_COLOR_PAL_IDX, BLUE_DISABLED_BTN_MAIN_COLOR_PAL_IDX,
330static bool use_seed =
false;
335#pragma region SEED KEYBOARD
340#define KEYBOARD_WIDTH 10
341#define KEYBOARD_HEIGHT 4
345 RUN_SETUP_SEED_ROW_KEY0,
346 RUN_SETUP_SEED_ROW_KEY1,
347 RUN_SETUP_SEED_ROW_KEY2,
348 RUN_SETUP_SEED_ROW_KEY3,
349 RUN_SETUP_SEED_ROW_DECK_PLAY,
350 RUN_SETUP_SEED_ROW_BACK,
351 RUN_SETUP_SEED_ROW_MAX
354enum RunSetupKeyboardButtons
356 RUN_SETUP_KEYBOARD_BEGIN,
358 RUN_SETUP_KEYBOARD_1 = RUN_SETUP_KEYBOARD_BEGIN,
359 RUN_SETUP_KEYBOARD_2,
360 RUN_SETUP_KEYBOARD_3,
361 RUN_SETUP_KEYBOARD_4,
362 RUN_SETUP_KEYBOARD_5,
363 RUN_SETUP_KEYBOARD_6,
364 RUN_SETUP_KEYBOARD_7,
365 RUN_SETUP_KEYBOARD_8,
366 RUN_SETUP_KEYBOARD_9,
367 RUN_SETUP_KEYBOARD_0,
369 RUN_SETUP_KEYBOARD_A,
370 RUN_SETUP_KEYBOARD_B,
371 RUN_SETUP_KEYBOARD_C,
372 RUN_SETUP_KEYBOARD_D,
373 RUN_SETUP_KEYBOARD_E,
374 RUN_SETUP_KEYBOARD_F,
375 RUN_SETUP_KEYBOARD_G,
376 RUN_SETUP_KEYBOARD_H,
377 RUN_SETUP_KEYBOARD_I,
378 RUN_SETUP_KEYBOARD_J,
380 RUN_SETUP_KEYBOARD_K,
381 RUN_SETUP_KEYBOARD_L,
382 RUN_SETUP_KEYBOARD_M,
383 RUN_SETUP_KEYBOARD_N,
384 RUN_SETUP_KEYBOARD_O,
385 RUN_SETUP_KEYBOARD_P,
386 RUN_SETUP_KEYBOARD_Q,
387 RUN_SETUP_KEYBOARD_R,
388 RUN_SETUP_KEYBOARD_S,
389 RUN_SETUP_KEYBOARD_T,
391 RUN_SETUP_KEYBOARD_RAND,
392 RUN_SETUP_KEYBOARD_U,
393 RUN_SETUP_KEYBOARD_V,
394 RUN_SETUP_KEYBOARD_W,
395 RUN_SETUP_KEYBOARD_X,
396 RUN_SETUP_KEYBOARD_Y,
397 RUN_SETUP_KEYBOARD_Z,
398 RUN_SETUP_KEYBOARD_DEL,
399 RUN_SETUP_KEYBOARD_MAX
402enum RunSetupSeedBottomButtons
404 RUN_SETUP_SEED_BB_PLAY,
405 RUN_SETUP_SEED_BB_DECK,
406 RUN_SETUP_SEED_BB_MAX
418 const Selection* prev_selection,
419 const Selection* new_selection
426 RUN_SETUP_SEED_ROW_KEY0,
432 RUN_SETUP_SEED_ROW_KEY1,
438 RUN_SETUP_SEED_ROW_KEY2,
444 RUN_SETUP_SEED_ROW_KEY3,
452 RUN_SETUP_SEED_ROW_DECK_PLAY,
458 RUN_SETUP_SEED_ROW_BACK,
461 back_row_on_key_transit,
467static const Selection RUN_SETUP_CHOOSE_SEED_INIT_SEL = {1, 4};
470 choose_seed_selection_rows,
471 RUN_SETUP_SEED_ROW_MAX,
472 RUN_SETUP_CHOOSE_SEED_INIT_SEL
481#define DEF_SEED_KEYBOARD_BUTTON_OBJECT(key) \
483 KEYBOARD_##key##_BTN_OUTLINE_COLOR_PAL_IDX, RED_BTN_MAIN_COLOR_PAL_IDX, \
484 keyboard_button_on_pressed, NULL \
488static Button keyboard_buttons[KEYBOARD_HEIGHT * KEYBOARD_WIDTH] = {
490 DEF_SEED_KEYBOARD_BUTTON_OBJECT(1),
491 DEF_SEED_KEYBOARD_BUTTON_OBJECT(2),
492 DEF_SEED_KEYBOARD_BUTTON_OBJECT(3),
493 DEF_SEED_KEYBOARD_BUTTON_OBJECT(4),
494 DEF_SEED_KEYBOARD_BUTTON_OBJECT(5),
495 DEF_SEED_KEYBOARD_BUTTON_OBJECT(6),
496 DEF_SEED_KEYBOARD_BUTTON_OBJECT(7),
497 DEF_SEED_KEYBOARD_BUTTON_OBJECT(8),
498 DEF_SEED_KEYBOARD_BUTTON_OBJECT(9),
499 DEF_SEED_KEYBOARD_BUTTON_OBJECT(0),
501 DEF_SEED_KEYBOARD_BUTTON_OBJECT(A),
502 DEF_SEED_KEYBOARD_BUTTON_OBJECT(B),
503 DEF_SEED_KEYBOARD_BUTTON_OBJECT(C),
504 DEF_SEED_KEYBOARD_BUTTON_OBJECT(D),
505 DEF_SEED_KEYBOARD_BUTTON_OBJECT(E),
506 DEF_SEED_KEYBOARD_BUTTON_OBJECT(F),
507 DEF_SEED_KEYBOARD_BUTTON_OBJECT(G),
508 DEF_SEED_KEYBOARD_BUTTON_OBJECT(H),
509 DEF_SEED_KEYBOARD_BUTTON_OBJECT(I),
510 DEF_SEED_KEYBOARD_BUTTON_OBJECT(J),
512 DEF_SEED_KEYBOARD_BUTTON_OBJECT(K),
513 DEF_SEED_KEYBOARD_BUTTON_OBJECT(L),
514 DEF_SEED_KEYBOARD_BUTTON_OBJECT(M),
515 DEF_SEED_KEYBOARD_BUTTON_OBJECT(N),
516 DEF_SEED_KEYBOARD_BUTTON_OBJECT(O),
517 DEF_SEED_KEYBOARD_BUTTON_OBJECT(P),
518 DEF_SEED_KEYBOARD_BUTTON_OBJECT(Q),
519 DEF_SEED_KEYBOARD_BUTTON_OBJECT(R),
520 DEF_SEED_KEYBOARD_BUTTON_OBJECT(S),
521 DEF_SEED_KEYBOARD_BUTTON_OBJECT(T),
523 DEF_SEED_KEYBOARD_BUTTON_OBJECT(RAND),
524 DEF_SEED_KEYBOARD_BUTTON_OBJECT(U),
525 DEF_SEED_KEYBOARD_BUTTON_OBJECT(V),
526 DEF_SEED_KEYBOARD_BUTTON_OBJECT(W),
527 DEF_SEED_KEYBOARD_BUTTON_OBJECT(X),
528 DEF_SEED_KEYBOARD_BUTTON_OBJECT(Y),
529 DEF_SEED_KEYBOARD_BUTTON_OBJECT(Z),
530 DEF_SEED_KEYBOARD_BUTTON_OBJECT(DEL)
533static Button choose_seed_bottom_buttons[2] = {
535 PLAY_BTN_OUTLINE_COLOR_PAL_IDX, BLUE_BTN_MAIN_COLOR_PAL_IDX,
538 SEED_DECK_BTN_OUTLINE_COLOR_PAL_IDX, BLUE_BTN_MAIN_COLOR_PAL_IDX,
543static const char KEYBOARD_BUTTONS_TO_CHAR[KEYBOARD_HEIGHT * KEYBOARD_WIDTH] = {
544 '1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'0',
545 'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
546 'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
547 ' ',
'U',
'V',
'W',
'X',
'Y',
'Z'
552static char s_seed_str[BASE36_MAX_DIGITS + 1] = {
'\0'};
553static u8 s_seed_cursor_pos = 0;
562enum RunSetupResumeRows
564 RUN_SETUP_RESUME_ROW_PLAY,
565 RUN_SETUP_RESUME_ROW_BACK,
566 RUN_SETUP_RESUME_ROW_MAX
575#pragma region STATE FUNCTIONS
583 GRIT_CPY(pal_bg_mem, background_run_setup_gfxPal);
584 GRIT_CPY(&tile_mem[MAIN_BG_CBB], background_run_setup_gfxTiles);
585 GRIT_CPY(&se_mem[MAIN_BG_SBB], background_run_setup_gfxMap);
594 if (g_game_vars.rng_info.
seed == UNDEFINED)
597 memset(s_seed_str,
'\0', BASE36_MAX_DIGITS + 1);
598 s_seed_cursor_pos = 0;
604 s_seed_cursor_pos = BASE36_MAX_DIGITS;
610 run_setup_deck = card_object_new(card_new(SPADES, ACE));
614 card_object_set_sprite_face_down(run_setup_deck, g_game_vars.deck, 0);
618 RUN_SETUP_DECK_SPRITE_T_X,
619 RUN_SETUP_DECK_SPRITE_T_Y
631 choose_deck_selection_grid.selection = RUN_SETUP_CHOOSE_DECK_INIT_SEL;
644 card_destroy(&run_setup_deck->card);
645 card_object_destroy(&run_setup_deck);
652#pragma region IMPLEMENTATION
671 RUN_SETUP_CHOOSE_DECK_CLEAN_LEFT_DEST,
672 RUN_SETUP_FRAME_BG_SE_FILL_SRC_POS
675 RUN_SETUP_CHOOSE_DECK_CLEAN_RIGHT_DEST,
676 RUN_SETUP_FRAME_BG_SE_FILL_SRC_POS
679 RUN_SETUP_CHOOSE_DECK_CHOICE_BG_9_PTCH_DEST,
680 &RUN_SETUP_CHOOSE_DECK_CHOICE_BG_9_PTCH_SRC
699 "#{P:%d,%d; cx:0x%X000}%s",
700 RUN_SETUP_PLAY_TEXT_POS.x,
701 RUN_SETUP_PLAY_TEXT_POS.y,
706 "#{P:%d,%d; cx:0x%X000}%s",
707 RUN_SETUP_BACK_TEXT_POS.x,
708 RUN_SETUP_BACK_TEXT_POS.y,
743 case RUN_SETUP_DECK_ROW_CHANGE_DECK:
744 return &change_deck_button;
746 case RUN_SETUP_DECK_ROW_SEED_PLAY:
747 if (sel->x >= RUN_SETUP_DECK_BB_MAX)
749 return &choose_deck_bottom_buttons[sel->x];
751 case RUN_SETUP_DECK_ROW_BACK:
769 const Selection* prev_selection,
770 const Selection* new_selection
800 if (key_hit(SELECT_CARD))
801 button_press(&choose_deck_bottom_buttons[selection->x]);
812 "#{P:%d,%d; cx:0x%X000}%-*s",
813 RUN_SETUP_SEED_FIELD_TEXT_POS.x,
814 RUN_SETUP_SEED_FIELD_TEXT_POS.y,
816 BASE36_MAX_DIGITS + 1,
826 choose_seed_selection_grid.selection = RUN_SETUP_CHOOSE_SEED_INIT_SEL;
834 RUN_SETUP_CHOOSE_SEED_FRAME_CLEAN_DEST,
835 RUN_SETUP_FRAME_BG_SE_FILL_SRC_POS
840 RUN_SETUP_CHOOSE_SEED_KEYBOARD_SRC,
841 RUN_SETUP_CHOOSE_SEED_KEYBOARD_DEST_POS
847 RUN_SETUP_CHOOSE_SEED_DECK_BTN_DEST,
848 RUN_SETUP_CHOOSE_SEED_DECK_BTN_3X3_SRC_POS
851 "#{P:%d,%d; cx:0x%X000}%s",
852 RUN_SETUP_SEED_DECK_TEXT_POS.x,
853 RUN_SETUP_SEED_DECK_TEXT_POS.y,
859 for (
enum RunSetupKeyboardButtons key = RUN_SETUP_KEYBOARD_BEGIN; key < RUN_SETUP_KEYBOARD_MAX;
888 return KEYBOARD_WIDTH;
898 return KEYBOARD_WIDTH - 2;
923 s_seed_cursor_pos = BASE36_MAX_DIGITS;
931 if (s_seed_cursor_pos == 0)
934 s_seed_str[--s_seed_cursor_pos] =
'\0';
945 if (s_seed_cursor_pos >= BASE36_MAX_DIGITS)
948 s_seed_str[s_seed_cursor_pos++] = KEYBOARD_BUTTONS_TO_CHAR[key];
961 return sel->x + KEYBOARD_WIDTH * sel->y;
970 if (choose_seed_selection_grid.selection.y > RUN_SETUP_SEED_ROW_KEY3)
977 if (s_seed_cursor_pos > BASE36_MAX_DIGITS)
978 s_seed_cursor_pos = BASE36_MAX_DIGITS;
980 if (key_hit(DESELECT_CARDS))
983 else if (key_hit(SELECT_CARD))
986 enum RunSetupKeyboardButtons key =
991 case RUN_SETUP_KEYBOARD_RAND:
996 case RUN_SETUP_KEYBOARD_DEL:
1017 case RUN_SETUP_SEED_ROW_KEY0:
1018 case RUN_SETUP_SEED_ROW_KEY1:
1019 case RUN_SETUP_SEED_ROW_KEY2:
1020 case RUN_SETUP_SEED_ROW_KEY3:
1023 case RUN_SETUP_SEED_ROW_DECK_PLAY:
1024 return &choose_seed_bottom_buttons[sel->x];
1026 case RUN_SETUP_SEED_ROW_BACK:
1027 return &back_button;
1042 if (key_hit(SELECT_CARD) ||
1043 (selection->y <= RUN_SETUP_SEED_ROW_KEY3 && key_hit(DESELECT_CARDS)))
1061 const Selection* prev_selection,
1062 const Selection* new_selection
1067 bool proceed_selection =
true;
1069 if (row_idx == prev_selection->y)
1072 if (row_idx == new_selection->y)
1074 Selection shifted_selection = *new_selection;
1077 if (prev_selection->y == RUN_SETUP_SEED_ROW_KEY2 &&
1078 new_selection->y == RUN_SETUP_SEED_ROW_KEY3 && prev_selection->x >= 5 &&
1079 prev_selection->x <= 8)
1081 shifted_selection.x++;
1082 selection_grid->selection = shifted_selection;
1083 proceed_selection =
false;
1087 else if (prev_selection->y == RUN_SETUP_SEED_ROW_KEY3 &&
1088 new_selection->y == RUN_SETUP_SEED_ROW_KEY2 && prev_selection->x >= 1 &&
1089 prev_selection->x <= 3)
1091 shifted_selection.x++;
1092 selection_grid->selection = shifted_selection;
1093 proceed_selection =
false;
1099 return proceed_selection;
1108 choose_deck_selection_grid.selection = RUN_SETUP_CHOOSE_DECK_SEL_FROM_SEED;
1140 choose_deck_bottom_buttons[RUN_SETUP_DECK_BB_SEED].
button_pal_idx =
1141 use_seed ? BLUE_BTN_MAIN_COLOR_PAL_IDX : BLUE_DISABLED_BTN_MAIN_COLOR_PAL_IDX;
1145 BG_POINT button_tiles = use_seed ? RUN_SETUP_CHOOSE_DECK_SEED_BTN_3X3_SRC_POS
1146 : RUN_SETUP_CHOOSE_DECK_SEED_BTN_DISABLED_3X3_SRC_POS;
1151 "#{P:%d,%d; cx:0x%X000}%s",
1152 RUN_SETUP_SEED_DECK_TEXT_POS.x,
1153 RUN_SETUP_SEED_DECK_TEXT_POS.y,
1154 use_seed ? TTE_WHITE_PB : TTE_BLACK_PB,
1159 Rect toggle_tiles = use_seed ? RUN_SETUP_CHOOSE_DECK_USE_SEED_BTN_ON_SRC
1160 : RUN_SETUP_CHOOSE_DECK_USE_SEED_BTN_OFF_SRC;
1188 if (use_seed && strlen(s_seed_str) > 0)
1195 game_change_state(GAME_STATE_GAME_START);
1203 game_change_state(GAME_STATE_MAIN_MENU);
1221 for (
enum RunSetupTab tab = 0; tab < RUN_SETUP_TAB_MAX; tab++)
1232 static enum RunSetupTab current_tab = RUN_SETUP_TAB_RESUME;
1236 if (!key_hit(KEY_ANY) || !is_saved_game_valid)
1240 if (key_hit(TAB_RIGHT) && current_tab < RUN_SETUP_TAB_MAX - 1)
1246 else if (key_hit(TAB_LEFT) && current_tab > 0)
1254 switch (current_tab)
1256 case RUN_SETUP_TAB_NEW_RUN:
1260 case RUN_SETUP_TAB_RESUME:
1279static void back_row_on_key_transit(
SelectionGrid* selection_grid, Selection* selection)
1281 if (key_hit(SELECT_CARD))
void print_deck_name(enum DeckType deck, BG_POINT pos)
Prints the Deck name string to the screen at the given position.
void print_deck_description(enum DeckType deck, BG_POINT pos)
Prints the Deck description string to the screen at the given position.
Game global game variables struct definition.
Graphic utility functions.
void main_bg_se_copy_rect(Rect se_rect, BG_POINT dest_pos)
Copies a rect in the main background from se_rect to the position (x, y).
void main_bg_se_copy_expand_3x3_rect(Rect se_rect_dest, BG_POINT se_rect_src_3x3_top_left)
Copies a 3x3 rect and expands it to fit a passed rect. Special case of the 9-patch.
void tte_erase_rect_wrapper(Rect rect)
A wrapper for tte_erase_rect that would use the rect struct.
void main_bg_se_copy_expand_9_patch(Rect se_dest_rect, const NinePatchRect *src_9_ptch)
Copies a 9-patch and expands it to fit a passed rect.
void main_bg_se_copy_expand_tile(Rect se_rect_dest, BG_POINT se_tile_src)
Copies a tile in the main background at se_tile_src to fill se_rect_dest.
void rng_shuffle_seed(void)
Sets a new randomized seed for the RNG using a source of entropy.
void rng_set_seed(u32 seed)
Set the rng seed to the chosen value, and reset the step counter to 0. The seed will be capped at MAX...
static Button * change_deck_get_button_from_sel(const Selection *sel)
Gets the Button corresponding to the current Selection in choose_deck_selection_grid
static int back_row_get_size(void)
Retuns the width of the Back button's row.
static void keyboard_button_on_pressed(void)
Keyboard key Button callback.
static void delete_seed_char(void)
Deletes the last char in the seed string base-36 representation.
void run_setup_on_exit(void)
Run Setup menu cleanup.
static void seed_on_pressed(void)
Seed Button Callback. Opens the seed input keyboard.
static void seed_keyboard_substate_update(void)
Update the Choose Seed substate by handling user inputs though the corresponding choose_seed_selectio...
static void update_seed_text(void)
Prints the string representing the chosen seed in base-36.
void run_setup_change_background(void)
Change to the Run Setup menu background.
static void back_on_pressed(void)
Back Button Callback. Goes back to the Main Menu.
static enum RunSetupKeyboardButtons get_keyboard_index_from_sel(const Selection *sel)
Get the keyboard key index from a SelectionGrid's Selection. The returned value is valid only if the ...
static void toggle_seed_enabled(bool enable)
Toggle whether or not we will use the seed chosen by the user. Changes the looks of the Seed button t...
static void play_on_pressed(void)
Play Button Callback. Applies the chosen seed if enabled and starts a new run.
static Button * choose_seed_get_button_from_sel(const Selection *sel)
Get the Button corresponding to a Selection within choose_seed_selection_grid
void run_setup_on_update(void)
Run Setup menu state update.
static void tab_set_highlight(enum RunSetupTab tab_sel)
Highlights the tab_sel Tab at the top of the screen, and removes highlight from all the others.
static void change_deck_on_pressed(void)
Button Callback used for cycling through the Decks.
void run_setup_on_init(void)
Run Setup menu state initialization.
static int choose_seed_get_bottom_row_size(void)
Returns the width of the Deck/Play buttons' row.
static int choose_seed_get_keyboard_short_row_size(void)
Returns the width of the bottom keyboard row, the shortest one.
static void choose_deck_substate_update(void)
Update the deck changing substate by handling user input though its corresponding SelectionGrid.
static bool choose_seed_row_on_selection_changed(SelectionGrid *selection_grid, int row_idx, const Selection *prev_selection, const Selection *new_selection)
Handle directional imputs in choose_seed_selection_grid
static void choose_seed_row_on_key_transit(SelectionGrid *selection_grid, Selection *selection)
Handle button imputs in choose_seed_selection_grid
static void seed_keyboard_substate_init(void)
Initialize the Choose Seed substate.
static void seed_play_row_on_key_transit(SelectionGrid *selection_grid, Selection *selection)
Handle button inputs for choose_deck_selection_grid
static int seed_play_get_row_size(void)
Returns the width of the Seed checkbox/Seed/Play buttons' row.
static void reroll_seed_str(void)
Deletes the last char in the seed string base-36 representation.
static void run_setup_tabs_update(void)
Handle user input in regards to the Tabs. Tabs are cycled through using the L/R buttons.
static void resume_substate_init(void)
Initialize the "Resume Previous Run" substate.
static int change_deck_get_row_size(void)
Returns the width of the Change Deck Button's row.
static void deck_on_pressed(void)
Deck Button Callback.
static void use_seed_on_pressed(void)
Seed checkbox Button Callback. Toggles custom seed usage.
static void choose_deck_substate_init(void)
Initializes the Deck changing substate.
static void type_seed_char(enum RunSetupKeyboardButtons key)
Add a new char at the end of the seed string.
static int choose_seed_get_keyboard_row_size(void)
Returns the width of the 3 top keyboard rows.
static bool choose_deck_row_on_selection_changed(SelectionGrid *selection_grid, int row_idx, const Selection *prev_selection, const Selection *new_selection)
Handle directional input in choose_deck_selection_grid
Setup Run menu state functions.
Utils functions to save/load data structures from/to the SRAM.
An implementation for a selection grid that handles directional selection.
void selection_grid_process_input(SelectionGrid *selection_grid)
Processes user input for the selection grid.
Sprite system for Gbalatro.
void sprite_object_unhide(SpriteObject *sprite_object)
Unhides the SpriteObject by manipulating ATTR0_HIDE in OAM. The sprite's ATTR0_MODE is maintained fro...
INLINE void sprite_object_position(SpriteObject *sprite_object, int x, int y)
Set sprite_object position. Inlined for efficiency.
void sprite_object_hide(SpriteObject *sprite_object)
Hides the SpriteObject by manipulating ATTR0_HIDE in OAM.
void state_machine_remove(StateMachine *state_machine)
Remove a statemachine's update function.
void state_machine_register(StateMachine *state_machine)
Register a statemachine to run it's update function once per frame.
void noop(void)
no operation
void state_machine_change_state(StateMachine *state_machine, int new_state)
Calls the current state's on_exit, the new state's on_init, and sets the active update fn.
Structure to represent arbitrary-sized 9-patches.
The core selection grid struct, represents the grid itself and its state.
A sprite object is a sprite that is focusable and movable in animation.
StateInfo * state_infos
Array of StateCallbacks , one entry per state.
Utilities relating around number string representation and protected arithmatic helper functions.
uint32_t base36_to_u32(const char b36_str[])
Convert a base-36 string representation to a 32-bit unsigned integer. Since we are dealing with base-...
void u32_to_base36(uint32_t n, char b36_str[])
Convert a 32-bit unsigned integer to its base-36 string representation. This will perform 6 divisions...