5#include "background_main_menu_gfx.h"
20#include <tonc_memdef.h>
22#define PLAY_BUTTON_MAIN_COLOR_PID 1
23#define PLAY_BUTTON_OUTLINE_PID 2
24#define OPTIONS_BUTTON_MAIN_COLOR_PID 3
25#define OPTIONS_BUTTON_OUTLINE_PID 4
35#define MAIN_MENU_ACE_T_X 88
36#define MAIN_MENU_ACE_T_Y 26
39static const BG_POINT GBALATRO_VERSION_TEXT_POS = {0, 152};
40static const Rect GBALATRO_VERSION_TEXT_RECT = {0, 152, 240, 160};
45static int main_menu_return_row_size(
void);
46static bool main_menu_on_selection_changed(
49 const Selection* prev_selection,
50 const Selection* new_selection
52static void main_menu_on_key_transit(
SelectionGrid* selection_grid, Selection* selection);
54static void play_on_pressed(
void);
55static void options_on_pressed(
void);
61 main_menu_return_row_size,
62 main_menu_on_selection_changed,
63 main_menu_on_key_transit,
68static Button main_menu_buttons[] = {
69 {PLAY_BUTTON_OUTLINE_PID, PLAY_BUTTON_MAIN_COLOR_PID, play_on_pressed, NULL},
70 {OPTIONS_BUTTON_OUTLINE_PID, OPTIONS_BUTTON_MAIN_COLOR_PID, options_on_pressed, NULL},
74 main_menu_selection_rows,
84static enum MainButtons s_last_highlighted_button = PLAY_BTN_IDX;
91 GRIT_CPY(pal_bg_mem, background_main_menu_gfxPal);
92 GRIT_CPY(&tile_mem[MAIN_BG_CBB], background_main_menu_gfxTiles);
93 GRIT_CPY(&se_mem[MAIN_BG_SBB], background_main_menu_gfxMap);
96 for (
int i = 0; i < MAIN_MENU_NB_BTN; i++)
106 s_main_menu_ace = card_object_new(card_new(SPADES, ACE));
107 card_object_set_sprite(s_main_menu_ace, 0);
109 s_main_menu_ace->sprite->obj->attr0 |= ATTR0_AFF_DBL;
110 s_main_menu_ace->tscale = float2fx(0.8f);
115 Selection sel_init = {s_last_highlighted_button, 0};
116 main_menu_selection_grid.selection = sel_init;
124 s_main_menu_ace->trotation = lu_sin((g_game_vars.timer << 8) / 2) / 3;
132 s_last_highlighted_button = main_menu_selection_grid.selection.x;
136 card_destroy(&s_main_menu_ace->card);
137 card_object_destroy(&s_main_menu_ace);
142static int main_menu_return_row_size(
void)
144 return MAIN_MENU_NB_BTN;
147static bool main_menu_on_selection_changed(
150 const Selection* prev_selection,
151 const Selection* new_selection
154 if (prev_selection->x >= 0 && prev_selection->x < MAIN_MENU_NB_BTN)
165static void main_menu_on_key_transit(
SelectionGrid* selection_grid, Selection* selection)
168 static bool combo_pressed =
false;
169 static bool show_version =
false;
170 if (key_is_down(KEY_START) && key_is_down(KEY_SELECT) && key_is_down(KEY_L) &&
175 show_version = !show_version;
179 "#{P:%d,%d; cx:0x%X000}%s",
180 GBALATRO_VERSION_TEXT_POS.x,
181 GBALATRO_VERSION_TEXT_POS.y,
192 combo_pressed =
true;
196 combo_pressed =
false;
199 if (key_hit(SELECT_CARD))
205static void play_on_pressed(
void)
207 game_change_state(GAME_STATE_RUN_SETUP);
210static void options_on_pressed(
void)
212 game_change_state(GAME_STATE_OPTIONS_MENU);
Utilities for affine background on GBA.
@ AFFINE_BG_MAIN_MENU
Display background for main menu.
void affine_background_change_background(enum AffineBackgroundID new_bg)
Update the background id.
Utilities for using maxmod to play sound effects.
#define MM_BASE_PITCH_RATE
The default pitch rate for the sound effect played.
void play_sfx(mm_word id, mm_word rate, mm_byte volume)
Play a sound effect, wrapper for mmEffectEx() See https://maxmod.org/ref/functions/mm_sound_effect....
Common functions to render UI elements.
void change_background(enum BackgroundId id, bool force_redraw)
Game global game variables struct definition.
Graphic utility functions.
void toggle_windows(bool win0, bool win1)
Toggles the visibility of the window layers.
void tte_erase_rect_wrapper(Rect rect)
A wrapper for tte_erase_rect that would use the rect struct.
Main menu state functions.
void game_main_menu_on_update(void)
Main menu state update.
void game_main_menu_on_exit(void)
Main menu cleanup (called when transitioning to game start)
void game_main_menu_change_background(void)
Change the main menu background.
void game_main_menu_on_init(void)
Main menu state initialization.
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.
INLINE void sprite_object_position(SpriteObject *sprite_object, int x, int y)
Set sprite_object position. Inlined for efficiency.
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.
Game ROM version global var declaration.