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
107 .num_infos = RUN_SETUP_SUBSTATE_MAX,
120static const BG_POINT RUN_SETUP_FRAME_BG_SE_FILL_SRC_POS = {9 , 31};
122static const Rect RUN_SETUP_CHOOSE_DECK_CHOICE_BG_9_PTCH_DEST = {6 , 4 , 23, 13};
123static const NinePatchRect RUN_SETUP_CHOOSE_DECK_CHOICE_BG_9_PTCH_SRC = {
128static const Rect RUN_SETUP_CHOOSE_DECK_CLEAN_LEFT_DEST = {4 , 6 , 5 , 13};
129static const Rect RUN_SETUP_CHOOSE_DECK_CLEAN_RIGHT_DEST = {24, 6 ,25 , 13};
131static const Rect RUN_SETUP_CHOOSE_DECK_USE_SEED_BTN_OFF_SRC = {30, 8 , 31, 10};
132static const Rect RUN_SETUP_CHOOSE_DECK_USE_SEED_BTN_ON_SRC = {30, 11, 31, 13};
133static const BG_POINT RUN_SETUP_CHOOSE_DECK_USE_SEED_BTN_DEST_POS = {17, 14};
135static const BG_POINT RUN_SETUP_CHOOSE_DECK_SEED_BTN_3X3_SRC_POS = {0 , 29};
136static const BG_POINT RUN_SETUP_CHOOSE_DECK_SEED_BTN_DISABLED_3X3_SRC_POS = {3 , 29};
137static const Rect RUN_SETUP_CHOOSE_DECK_SEED_BTN_DEST = {19, 14, 24, 16};
139static const Rect RUN_SETUP_CHOOSE_SEED_FRAME_CLEAN_DEST = {4 , 3 , 25, 5 };
140static const Rect RUN_SETUP_CHOOSE_SEED_KEYBOARD_SRC = {10, 24, 31, 31};
141static const Rect RUN_SETUP_CHOOSE_SEED_FIELD_SRC = {24, 22, 31, 23};
142static const BG_POINT RUN_SETUP_CHOOSE_SEED_KEYBOARD_DEST_POS = {4 , 6};
143static const BG_POINT RUN_SETUP_CHOOSE_SEED_FIELD_DEST_POS = {11, 4};
145static const BG_POINT RUN_SETUP_CHOOSE_SEED_DECK_BTN_3X3_SRC_POS = RUN_SETUP_CHOOSE_DECK_SEED_BTN_3X3_SRC_POS;
146static const Rect RUN_SETUP_CHOOSE_SEED_DECK_BTN_DEST = {17, 14, 24, 16};
149#define RUN_SETUP_DECK_SPRITE_T_X 48
150#define RUN_SETUP_DECK_SPRITE_T_Y 54
151static const BG_POINT RUN_SETUP_DECK_NAME_TEXT_POS = {80 , 40 };
152static const BG_POINT RUN_SETUP_DECK_DESC_TEXT_POS = {80 , 56 };
153static const Rect RUN_SETUP_DECK_NAME_DESC_RECT = {80 , 40 ,176, 96 };
154static const BG_POINT RUN_SETUP_SEED_FIELD_TEXT_POS = {96 , 40 };
155static const BG_POINT RUN_SETUP_SEED_DECK_TEXT_POS = {152, 120};
156static const BG_POINT RUN_SETUP_PLAY_TEXT_POS = {76 , 120};
157static const BG_POINT RUN_SETUP_BACK_TEXT_POS = {104, 136};
162#pragma region TAB BAR
172 RUN_SETUP_TAB_NEW_RUN,
173 RUN_SETUP_TAB_RESUME,
177static bool is_saved_game_valid =
false;
183static Button tabs_buttons[RUN_SETUP_TAB_MAX] = {
184 {NEW_RUN_BTN_OUTLINE_COLOR_PAL_IDX, RED_BTN_MAIN_COLOR_PAL_IDX, NULL, NULL},
185 {RESUME_BTN_OUTLINE_COLOR_PAL_IDX, RED_BTN_MAIN_COLOR_PAL_IDX, NULL, NULL},
191#pragma region BOTTOM BUTTONS
207static void back_row_on_key_transit(
SelectionGrid* selection_grid, Selection* selection);
217static Button back_button = {
218 BACK_BTN_OUTLINE_COLOR_PAL_IDX, BACK_BTN_MAIN_COLOR_PAL_IDX,
225#pragma region CHOOSE DECK
232 RUN_SETUP_DECK_ROW_CHANGE_DECK,
233 RUN_SETUP_DECK_ROW_SEED_PLAY,
234 RUN_SETUP_DECK_ROW_BACK,
235 RUN_SETUP_DECK_ROW_MAX
238enum RunSetupDeckBottomButtons
240 RUN_SETUP_DECK_BB_PLAY,
241 RUN_SETUP_DECK_BB_USE_SEED,
242 RUN_SETUP_DECK_BB_SEED,
243 RUN_SETUP_DECK_BB_MAX
252 const Selection* prev_selection,
253 const Selection* new_selection
261 RUN_SETUP_DECK_ROW_CHANGE_DECK,
267 RUN_SETUP_DECK_ROW_SEED_PLAY,
273 RUN_SETUP_DECK_ROW_BACK,
276 back_row_on_key_transit,
282static const Selection RUN_SETUP_CHOOSE_DECK_INIT_SEL = {0, 0};
283static const Selection RUN_SETUP_CHOOSE_DECK_SEL_FROM_SEED = {2, 1};
287 RUN_SETUP_DECK_ROW_MAX,
288 RUN_SETUP_CHOOSE_DECK_INIT_SEL
295static Button change_deck_button = {
296 CHANGE_DECK_BTN_OUTLINE_COLOR_PAL_IDX,
297 CHANGE_DECK_BTN_MAIN_COLOR_PAL_IDX,
304static Button choose_deck_bottom_buttons[RUN_SETUP_DECK_BB_MAX] = {
306 PLAY_BTN_OUTLINE_COLOR_PAL_IDX, BLUE_BTN_MAIN_COLOR_PAL_IDX,
309 SEED_CHECK_BTN_OUTLINE_COLOR_PAL_IDX, RED_BTN_MAIN_COLOR_PAL_IDX,
312 SEED_DECK_BTN_OUTLINE_COLOR_PAL_IDX, BLUE_DISABLED_BTN_MAIN_COLOR_PAL_IDX,
318static bool use_seed =
false;
323#pragma region SEED KEYBOARD
328#define KEYBOARD_WIDTH 10
329#define KEYBOARD_HEIGHT 4
333 RUN_SETUP_SEED_ROW_KEY0,
334 RUN_SETUP_SEED_ROW_KEY1,
335 RUN_SETUP_SEED_ROW_KEY2,
336 RUN_SETUP_SEED_ROW_KEY3,
337 RUN_SETUP_SEED_ROW_DECK_PLAY,
338 RUN_SETUP_SEED_ROW_BACK,
339 RUN_SETUP_SEED_ROW_MAX
342enum RunSetupKeyboardButtons
344 RUN_SETUP_KEYBOARD_BEGIN,
346 RUN_SETUP_KEYBOARD_1 = RUN_SETUP_KEYBOARD_BEGIN,
347 RUN_SETUP_KEYBOARD_2,
348 RUN_SETUP_KEYBOARD_3,
349 RUN_SETUP_KEYBOARD_4,
350 RUN_SETUP_KEYBOARD_5,
351 RUN_SETUP_KEYBOARD_6,
352 RUN_SETUP_KEYBOARD_7,
353 RUN_SETUP_KEYBOARD_8,
354 RUN_SETUP_KEYBOARD_9,
355 RUN_SETUP_KEYBOARD_0,
357 RUN_SETUP_KEYBOARD_A,
358 RUN_SETUP_KEYBOARD_B,
359 RUN_SETUP_KEYBOARD_C,
360 RUN_SETUP_KEYBOARD_D,
361 RUN_SETUP_KEYBOARD_E,
362 RUN_SETUP_KEYBOARD_F,
363 RUN_SETUP_KEYBOARD_G,
364 RUN_SETUP_KEYBOARD_H,
365 RUN_SETUP_KEYBOARD_I,
366 RUN_SETUP_KEYBOARD_J,
368 RUN_SETUP_KEYBOARD_K,
369 RUN_SETUP_KEYBOARD_L,
370 RUN_SETUP_KEYBOARD_M,
371 RUN_SETUP_KEYBOARD_N,
372 RUN_SETUP_KEYBOARD_O,
373 RUN_SETUP_KEYBOARD_P,
374 RUN_SETUP_KEYBOARD_Q,
375 RUN_SETUP_KEYBOARD_R,
376 RUN_SETUP_KEYBOARD_S,
377 RUN_SETUP_KEYBOARD_T,
379 RUN_SETUP_KEYBOARD_RAND,
380 RUN_SETUP_KEYBOARD_U,
381 RUN_SETUP_KEYBOARD_V,
382 RUN_SETUP_KEYBOARD_W,
383 RUN_SETUP_KEYBOARD_X,
384 RUN_SETUP_KEYBOARD_Y,
385 RUN_SETUP_KEYBOARD_Z,
386 RUN_SETUP_KEYBOARD_DEL,
387 RUN_SETUP_KEYBOARD_MAX
390enum RunSetupSeedBottomButtons
392 RUN_SETUP_SEED_BB_PLAY,
393 RUN_SETUP_SEED_BB_DECK,
394 RUN_SETUP_SEED_BB_MAX
406 const Selection* prev_selection,
407 const Selection* new_selection
414 RUN_SETUP_SEED_ROW_KEY0,
420 RUN_SETUP_SEED_ROW_KEY1,
426 RUN_SETUP_SEED_ROW_KEY2,
432 RUN_SETUP_SEED_ROW_KEY3,
440 RUN_SETUP_SEED_ROW_DECK_PLAY,
446 RUN_SETUP_SEED_ROW_BACK,
449 back_row_on_key_transit,
455static const Selection RUN_SETUP_CHOOSE_SEED_INIT_SEL = {1, 4};
458 choose_seed_selection_rows,
459 RUN_SETUP_SEED_ROW_MAX,
460 RUN_SETUP_CHOOSE_SEED_INIT_SEL
469#define DEF_SEED_KEYBOARD_BUTTON_OBJECT(key) \
471 KEYBOARD_##key##_BTN_OUTLINE_COLOR_PAL_IDX, RED_BTN_MAIN_COLOR_PAL_IDX, \
472 keyboard_button_on_pressed, NULL \
476static Button keyboard_buttons[KEYBOARD_HEIGHT * KEYBOARD_WIDTH] = {
478 DEF_SEED_KEYBOARD_BUTTON_OBJECT(1),
479 DEF_SEED_KEYBOARD_BUTTON_OBJECT(2),
480 DEF_SEED_KEYBOARD_BUTTON_OBJECT(3),
481 DEF_SEED_KEYBOARD_BUTTON_OBJECT(4),
482 DEF_SEED_KEYBOARD_BUTTON_OBJECT(5),
483 DEF_SEED_KEYBOARD_BUTTON_OBJECT(6),
484 DEF_SEED_KEYBOARD_BUTTON_OBJECT(7),
485 DEF_SEED_KEYBOARD_BUTTON_OBJECT(8),
486 DEF_SEED_KEYBOARD_BUTTON_OBJECT(9),
487 DEF_SEED_KEYBOARD_BUTTON_OBJECT(0),
489 DEF_SEED_KEYBOARD_BUTTON_OBJECT(A),
490 DEF_SEED_KEYBOARD_BUTTON_OBJECT(B),
491 DEF_SEED_KEYBOARD_BUTTON_OBJECT(C),
492 DEF_SEED_KEYBOARD_BUTTON_OBJECT(D),
493 DEF_SEED_KEYBOARD_BUTTON_OBJECT(E),
494 DEF_SEED_KEYBOARD_BUTTON_OBJECT(F),
495 DEF_SEED_KEYBOARD_BUTTON_OBJECT(G),
496 DEF_SEED_KEYBOARD_BUTTON_OBJECT(H),
497 DEF_SEED_KEYBOARD_BUTTON_OBJECT(I),
498 DEF_SEED_KEYBOARD_BUTTON_OBJECT(J),
500 DEF_SEED_KEYBOARD_BUTTON_OBJECT(K),
501 DEF_SEED_KEYBOARD_BUTTON_OBJECT(L),
502 DEF_SEED_KEYBOARD_BUTTON_OBJECT(M),
503 DEF_SEED_KEYBOARD_BUTTON_OBJECT(N),
504 DEF_SEED_KEYBOARD_BUTTON_OBJECT(O),
505 DEF_SEED_KEYBOARD_BUTTON_OBJECT(P),
506 DEF_SEED_KEYBOARD_BUTTON_OBJECT(Q),
507 DEF_SEED_KEYBOARD_BUTTON_OBJECT(R),
508 DEF_SEED_KEYBOARD_BUTTON_OBJECT(S),
509 DEF_SEED_KEYBOARD_BUTTON_OBJECT(T),
511 DEF_SEED_KEYBOARD_BUTTON_OBJECT(RAND),
512 DEF_SEED_KEYBOARD_BUTTON_OBJECT(U),
513 DEF_SEED_KEYBOARD_BUTTON_OBJECT(V),
514 DEF_SEED_KEYBOARD_BUTTON_OBJECT(W),
515 DEF_SEED_KEYBOARD_BUTTON_OBJECT(X),
516 DEF_SEED_KEYBOARD_BUTTON_OBJECT(Y),
517 DEF_SEED_KEYBOARD_BUTTON_OBJECT(Z),
518 DEF_SEED_KEYBOARD_BUTTON_OBJECT(DEL)
521static Button choose_seed_bottom_buttons[2] = {
523 PLAY_BTN_OUTLINE_COLOR_PAL_IDX, BLUE_BTN_MAIN_COLOR_PAL_IDX,
526 SEED_DECK_BTN_OUTLINE_COLOR_PAL_IDX, BLUE_BTN_MAIN_COLOR_PAL_IDX,
531static const char KEYBOARD_BUTTONS_TO_CHAR[KEYBOARD_HEIGHT * KEYBOARD_WIDTH] = {
532 '1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'0',
533 'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
534 'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
535 ' ',
'U',
'V',
'W',
'X',
'Y',
'Z'
540static char s_seed_str[BASE36_MAX_DIGITS + 1] = {
'\0'};
541static u8 s_seed_cursor_pos = 0;
550enum RunSetupResumeRows
552 RUN_SETUP_RESUME_ROW_PLAY,
553 RUN_SETUP_RESUME_ROW_BACK,
554 RUN_SETUP_RESUME_ROW_MAX
563#pragma region STATE FUNCTIONS
571 GRIT_CPY(pal_bg_mem, background_run_setup_gfxPal);
572 GRIT_CPY(&tile_mem[MAIN_BG_CBB], background_run_setup_gfxTiles);
573 GRIT_CPY(&se_mem[MAIN_BG_SBB], background_run_setup_gfxMap);
582 if (g_game_vars.rng_info.
seed == UNDEFINED)
585 memset(s_seed_str,
'\0', BASE36_MAX_DIGITS + 1);
586 s_seed_cursor_pos = 0;
592 s_seed_cursor_pos = BASE36_MAX_DIGITS;
598 run_setup_deck = card_object_new(card_new(SPADES, ACE));
602 card_object_set_sprite_face_down(run_setup_deck, g_game_vars.deck, 0);
606 RUN_SETUP_DECK_SPRITE_T_X,
607 RUN_SETUP_DECK_SPRITE_T_Y
619 choose_deck_selection_grid.selection = RUN_SETUP_CHOOSE_DECK_INIT_SEL;
632 card_destroy(&run_setup_deck->card);
633 card_object_destroy(&run_setup_deck);
640#pragma region IMPLEMENTATION
659 RUN_SETUP_CHOOSE_DECK_CLEAN_LEFT_DEST,
660 RUN_SETUP_FRAME_BG_SE_FILL_SRC_POS
663 RUN_SETUP_CHOOSE_DECK_CLEAN_RIGHT_DEST,
664 RUN_SETUP_FRAME_BG_SE_FILL_SRC_POS
667 RUN_SETUP_CHOOSE_DECK_CHOICE_BG_9_PTCH_DEST,
668 &RUN_SETUP_CHOOSE_DECK_CHOICE_BG_9_PTCH_SRC
687 "#{P:%d,%d; cx:0x%X000}%s",
688 RUN_SETUP_PLAY_TEXT_POS.x,
689 RUN_SETUP_PLAY_TEXT_POS.y,
694 "#{P:%d,%d; cx:0x%X000}%s",
695 RUN_SETUP_BACK_TEXT_POS.x,
696 RUN_SETUP_BACK_TEXT_POS.y,
731 case RUN_SETUP_DECK_ROW_CHANGE_DECK:
732 return &change_deck_button;
734 case RUN_SETUP_DECK_ROW_SEED_PLAY:
735 if (sel->x >= RUN_SETUP_DECK_BB_MAX)
737 return &choose_deck_bottom_buttons[sel->x];
739 case RUN_SETUP_DECK_ROW_BACK:
757 const Selection* prev_selection,
758 const Selection* new_selection
788 if (key_hit(SELECT_CARD))
789 button_press(&choose_deck_bottom_buttons[selection->x]);
800 "#{P:%d,%d; cx:0x%X000}%-*s",
801 RUN_SETUP_SEED_FIELD_TEXT_POS.x,
802 RUN_SETUP_SEED_FIELD_TEXT_POS.y,
804 BASE36_MAX_DIGITS + 1,
814 choose_seed_selection_grid.selection = RUN_SETUP_CHOOSE_SEED_INIT_SEL;
822 RUN_SETUP_CHOOSE_SEED_FRAME_CLEAN_DEST,
823 RUN_SETUP_FRAME_BG_SE_FILL_SRC_POS
828 RUN_SETUP_CHOOSE_SEED_KEYBOARD_SRC,
829 RUN_SETUP_CHOOSE_SEED_KEYBOARD_DEST_POS
835 RUN_SETUP_CHOOSE_SEED_DECK_BTN_DEST,
836 RUN_SETUP_CHOOSE_SEED_DECK_BTN_3X3_SRC_POS
839 "#{P:%d,%d; cx:0x%X000}%s",
840 RUN_SETUP_SEED_DECK_TEXT_POS.x,
841 RUN_SETUP_SEED_DECK_TEXT_POS.y,
847 for (
enum RunSetupKeyboardButtons key = RUN_SETUP_KEYBOARD_BEGIN; key < RUN_SETUP_KEYBOARD_MAX;
876 return KEYBOARD_WIDTH;
886 return KEYBOARD_WIDTH - 2;
911 s_seed_cursor_pos = BASE36_MAX_DIGITS;
919 if (s_seed_cursor_pos == 0)
922 s_seed_str[--s_seed_cursor_pos] =
'\0';
933 if (s_seed_cursor_pos >= BASE36_MAX_DIGITS)
936 s_seed_str[s_seed_cursor_pos++] = KEYBOARD_BUTTONS_TO_CHAR[key];
949 return sel->x + KEYBOARD_WIDTH * sel->y;
958 if (choose_seed_selection_grid.selection.y > RUN_SETUP_SEED_ROW_KEY3)
965 if (s_seed_cursor_pos > BASE36_MAX_DIGITS)
966 s_seed_cursor_pos = BASE36_MAX_DIGITS;
968 if (key_hit(DESELECT_CARDS))
971 else if (key_hit(SELECT_CARD))
974 enum RunSetupKeyboardButtons key =
979 case RUN_SETUP_KEYBOARD_RAND:
984 case RUN_SETUP_KEYBOARD_DEL:
1005 case RUN_SETUP_SEED_ROW_KEY0:
1006 case RUN_SETUP_SEED_ROW_KEY1:
1007 case RUN_SETUP_SEED_ROW_KEY2:
1008 case RUN_SETUP_SEED_ROW_KEY3:
1011 case RUN_SETUP_SEED_ROW_DECK_PLAY:
1012 return &choose_seed_bottom_buttons[sel->x];
1014 case RUN_SETUP_SEED_ROW_BACK:
1015 return &back_button;
1030 if (key_hit(SELECT_CARD) ||
1031 (selection->y <= RUN_SETUP_SEED_ROW_KEY3 && key_hit(DESELECT_CARDS)))
1049 const Selection* prev_selection,
1050 const Selection* new_selection
1055 bool proceed_selection =
true;
1057 if (row_idx == prev_selection->y)
1060 if (row_idx == new_selection->y)
1062 Selection shifted_selection = *new_selection;
1065 if (prev_selection->y == RUN_SETUP_SEED_ROW_KEY2 &&
1066 new_selection->y == RUN_SETUP_SEED_ROW_KEY3 && prev_selection->x >= 5 &&
1067 prev_selection->x <= 8)
1069 shifted_selection.x++;
1070 selection_grid->selection = shifted_selection;
1071 proceed_selection =
false;
1075 else if (prev_selection->y == RUN_SETUP_SEED_ROW_KEY3 &&
1076 new_selection->y == RUN_SETUP_SEED_ROW_KEY2 && prev_selection->x >= 1 &&
1077 prev_selection->x <= 3)
1079 shifted_selection.x++;
1080 selection_grid->selection = shifted_selection;
1081 proceed_selection =
false;
1087 return proceed_selection;
1096 choose_deck_selection_grid.selection = RUN_SETUP_CHOOSE_DECK_SEL_FROM_SEED;
1128 choose_deck_bottom_buttons[RUN_SETUP_DECK_BB_SEED].
button_pal_idx =
1129 use_seed ? BLUE_BTN_MAIN_COLOR_PAL_IDX : BLUE_DISABLED_BTN_MAIN_COLOR_PAL_IDX;
1133 BG_POINT button_tiles = use_seed ? RUN_SETUP_CHOOSE_DECK_SEED_BTN_3X3_SRC_POS
1134 : RUN_SETUP_CHOOSE_DECK_SEED_BTN_DISABLED_3X3_SRC_POS;
1139 "#{P:%d,%d; cx:0x%X000}%s",
1140 RUN_SETUP_SEED_DECK_TEXT_POS.x,
1141 RUN_SETUP_SEED_DECK_TEXT_POS.y,
1142 use_seed ? TTE_WHITE_PB : TTE_BLACK_PB,
1147 Rect toggle_tiles = use_seed ? RUN_SETUP_CHOOSE_DECK_USE_SEED_BTN_ON_SRC
1148 : RUN_SETUP_CHOOSE_DECK_USE_SEED_BTN_OFF_SRC;
1176 if (use_seed && strlen(s_seed_str) > 0)
1183 game_change_state(GAME_STATE_GAME_START);
1191 game_change_state(GAME_STATE_MAIN_MENU);
1209 for (
enum RunSetupTab tab = 0; tab < RUN_SETUP_TAB_MAX; tab++)
1220 static enum RunSetupTab current_tab = RUN_SETUP_TAB_RESUME;
1224 if (!key_hit(KEY_ANY) || !is_saved_game_valid)
1228 if (key_hit(TAB_RIGHT) && current_tab < RUN_SETUP_TAB_MAX - 1)
1234 else if (key_hit(TAB_LEFT) && current_tab > 0)
1242 switch (current_tab)
1244 case RUN_SETUP_TAB_NEW_RUN:
1248 case RUN_SETUP_TAB_RESUME:
1267static void back_row_on_key_transit(
SelectionGrid* selection_grid, Selection* selection)
1269 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.
void game_run_setup_change_background(void)
Change to the Run Setup menu background.
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.
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.
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 game_run_setup_on_exit(void)
Run Setup menu cleanup.
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.
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
void game_run_setup_on_update(void)
Run Setup menu state update.
static int seed_play_get_row_size(void)
Returns the width of the Seed checkbox/Seed/Play buttons' row.
void game_run_setup_on_init(void)
Run Setup menu state initialization.
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...