Merge branch 'main' of https://github.com/cellos51/balatro-gba into main_menu_and_splash_screen

This commit is contained in:
cellos51
2025-08-24 13:47:41 -04:00
27 changed files with 1260 additions and 472 deletions
+2
View File
@@ -35,6 +35,8 @@
#define NUM_RANKS 13
#define RANK_OFFSET 2 // Because the first rank is 2 and ranks start at 0
#define IMPOSSIBLY_HIGH_CARD_VALUE 100
// Card types
typedef struct
{
+10 -3
View File
@@ -24,6 +24,7 @@
#define PEEK_DECK KEY_L // Not implemented
#define SORT_HAND KEY_R
#define PAUSE_GAME KEY_START // Not implemented
#define SELL_KEY KEY_L
enum GameState
{
@@ -33,6 +34,7 @@ enum GameState
GAME_SHOP,
GAME_BLIND_SELECT,
GAME_LOSE,
GAME_WIN
};
enum HandState
@@ -76,6 +78,10 @@ enum HandType
void game_init();
void game_update();
// Forward declaration
struct List;
typedef struct List List;
// Utility functions for other files
typedef struct CardObject CardObject; // forward declaration, actually declared in card.h
typedef struct JokerObject JokerObject;
@@ -84,9 +90,10 @@ int get_hand_top(void);
int hand_get_size(void);
CardObject** get_played_array(void);
int get_played_top(void);
JokerObject** get_jokers(void);
int get_jokers_top(void);
List* get_jokers(void);
int get_deck_top(void);
int get_num_discards_remaining(void);
int get_money(void);
#endif // GAME_H
#endif // GAME_H
+56 -21
View File
@@ -1,6 +1,8 @@
#ifndef GRAPHIC_UTILS_H
#define GRAPHIC_UTILS_H
#include <tonc_video.h>
/* This file contains general utils and wrappers that relate to
* graphics/video/vram and generally displaying things on the screen.
* Mostly wrappers and defines for using tonc.
@@ -24,6 +26,19 @@
#define PAL_ROW_LEN 16
#define NUM_PALETTES 16
#define TTE_BIT_UNPACK_OFFSET 14
#define TTE_BIT_ON_CLR_IDX TTE_BIT_UNPACK_OFFSET + 1
#define TTE_YELLOW_PB 12 // 0xC
#define TTE_BLUE_PB 13 // 0xD
#define TTE_RED_PB 14 // 0xE
#define TTE_WHITE_PB 15 // 0xF
#define TEXT_CLR_YELLOW RGB15(31, 20, 0) // 0x029F
#define TEXT_CLR_BLUE RGB15(0, 18, 31) // 0x7E40
#define TEXT_CLR_RED RGB15(31, 9, 8) // 0x213F
#define TEXT_CLR_WHITE CLR_WHITE
/* Dimensions for a screenblock.
* A 1024 size screenblock is arranged in a grid of 32x32 screen entries
* Interestingly since each block is 8x8 pixels, the 240x160 GBA screen
@@ -34,45 +49,55 @@
#define SE_COL_LEN 32
// Since y direction goes from the top of the screen to the bottom
#define SE_UP -1
#define SE_DOWN 1
#define SCREEN_UP -1
#define SCREEN_DOWN 1
#define SCREEN_LEFT -1
#define SCREEN_RIGHT 1
#define OVERFLOW_LEFT -1
#define OVERFLOW_RIGHT 1
#define SE_UP SCREEN_UP
#define SE_DOWN SCREEN_DOWN
#define OVERFLOW_LEFT SCREEN_LEFT
#define OVERFLOW_RIGHT SCREEN_RIGHT
// Tile size in pixels, both height and width as tiles are square
#define TILE_SIZE 8
#define EFFECT_TEXT_SEPARATION_AMOUNT 32; // If we need to show multiple effects at once
// By default TTE characters occupy a single tile
#define TTE_CHAR_SIZE TILE_SIZE
typedef struct
{
int left;
int top;
int right;
int bottom;
} Rect;
// When making this, missed that it already exists in tonc_math.h
typedef RECT Rect;
/* Gets the screenblock tile for the given coordinates (x, y).
/* Gets the screenblock entry for the given coordinates (x, y).
* x and y are in number of tiles.
* Returns the screenblock tile.
* Returns the screenblock entry.
*/
u16 main_bg_se_get_tile(BG_POINT pos);
SE main_bg_se_get_se(BG_POINT pos);
INLINE int rect_width(const Rect* rect)
{
/* Extra parens to avoid issues in case compiler turns INLINE into macro
* Not sure if necessary, could be just paranoia
*/
return (((rect)->right) - ((rect)->left) + 1);
/* Extra parens to avoid issues in case compiler turns INLINE into macro
* Not sure if necessary, could be just paranoia
*/
return (((rect)->right) - ((rect)->left) + 1);
}
INLINE int rect_height(const Rect* rect)
{
return (((rect)->bottom) - ((rect)->top) + 1);
return (((rect)->bottom) - ((rect)->top) + 1);
}
/* Copies an SE rect vertically in direction by a single tile.
* bg_sbb is the SBB of the background in which to move the rect
* direction must be either SE_UP or SE_DOWN.
* se_rect dimensions are in number of tiles.
*
* NOTE: This does not work with TTE_SBB, probably because it's 4BPP...
*/
void bg_se_copy_rect_1_tile_vert(u16 bg_sbb, Rect se_rect, int direction);
/* Clears a rect in the main background.
* The se_rect dimensions need to be in number of tiles.
*/
@@ -90,11 +115,21 @@ void main_bg_se_copy_rect_1_tile_vert(Rect se_rect, int direction);
*/
void main_bg_se_copy_rect(Rect se_rect, BG_POINT pos);
/* Copies a tile to a rect in the main background.
/* Copies a screen entry to a rect in the main background.
* se_rect dimensions are in number of tiles.
* The tile is copied to the top left corner of the rect.
*/
void main_bg_se_copy_tile_to_rect(u16 tile, Rect se_rect);
void main_bg_se_fill_rect_with_se(SE tile, Rect se_rect);
/* Copies a 3x3 rect into se_rect_dest, the 3x3 rect is stretched to fill se_rect_dest.
* The corners are copied, the sides are stretched, and the center is filled.
* The parameter se_rect_src_3x3_top_left points to the top left corner of the source
* 3x3 rect.
* Dest rect sides can be of length 2, then the sides are not copied, only the corners.
* But dest rect sides must be at least 2.
*/
void main_bg_se_copy_expand_3x3_rect(Rect se_rect_dest, BG_POINT se_rect_src_3x3_top_left);
/* Moves a rect in the main background vertically in direction by a single tile.
* Note that tiles in the previous location will be transparent (0x000)
* so maybe copy would be a better choice if you don't want to delete things
+1
View File
@@ -78,6 +78,7 @@ void joker_destroy(Joker **joker);
// Unique effects like "Four Fingers" or "Credit Card" will be hard coded into game.c with a conditional check for the joker ID from the players owned jokers
// game.c should probably be restructured so most of the variables in it are moved to some sort of global variable header file so they can be easily accessed and modified for the jokers
JokerEffect joker_get_score_effect(Joker *joker, Card *scored_card);
int joker_get_sell_value(const Joker* joker);
JokerObject *joker_object_new(Joker *joker);
void joker_object_destroy(JokerObject **joker_object);
+3
View File
@@ -13,5 +13,8 @@
#include "joker_gfx9.h"
#include "joker_gfx10.h"
#include "joker_gfx11.h"
#include "joker_gfx12.h"
#include "joker_gfx13.h"
#include "joker_gfx14.h"
#endif
+14 -14
View File
@@ -3,23 +3,23 @@
#include <stdbool.h>
/* Defining an int list for simplicity
* If another list is needed, a generic void*
* list should be defined....
*/
typedef struct IntList
typedef struct List
{
int* _array;
void** _array;
int size;
int allocated_size;
} IntList;
} List;
IntList *int_list_new(int init_size);
void int_list_destroy(IntList **list);
bool int_list_append(IntList *list, int value);
bool int_list_remove_by_idx(IntList *list, int index);
int int_list_get(IntList *list, int index);
int int_list_get_size(IntList *list);
bool int_list_remove_by_value(IntList *list, int value);
List *list_new(int init_size);
void list_destroy(List **list);
bool list_append(List *list, void *value);
bool list_remove_by_idx(List *list, int index);
void* list_get(List *list, int index);
int list_get_size(List *list);
bool list_remove_by_value(List *list, void *value);
bool int_list_append(List *list, intptr_t value);
intptr_t int_list_get(List *list, int index);
bool int_list_remove_by_value(List *list, intptr_t value);
#endif
+41
View File
@@ -0,0 +1,41 @@
#ifndef SELECTION_GRID_H
#define SELECTION_GRID_H
#include <tonc.h>
typedef POINT Selection;
struct SelectionGridRow;
struct SelectionGrid;
typedef struct SelectionGridRow SelectionGridRow;
typedef struct SelectionGrid SelectionGrid;
// Called whenever there is a change in the selection cursor
// row_idx is the index of the row whose function is invoked - can be used to identify whether it is the previous or new selection row.
typedef void (*RowOnSelectionChangedFunc)(SelectionGrid* selection_grid, int row_idx, const Selection* prev_selection, const Selection* new_selection);
typedef int (*RowGetSizeFunc)();
// Called for any non-directional key hit
// The key will not be passed, the function will have to check key_hit() etc. for the key it wants to check
typedef void (*RowOnKeyHitFunc)(SelectionGrid* selection_grid, Selection* selection);
struct SelectionGridRow
{
int row_idx;
RowGetSizeFunc get_size;
RowOnSelectionChangedFunc on_selection_changed;
RowOnKeyHitFunc on_key_hit;
};
struct SelectionGrid
{
SelectionGridRow* rows;
const int num_rows;
Selection selection;
};
void selection_grid_process_input(SelectionGrid* selection_grid);
void selection_grid_move_selection_horz(SelectionGrid* selection_grid, int direction_tribool);
void selection_grid_move_selection_vert(SelectionGrid* selection_grid, int direction_tribool);
#endif
+4 -1
View File
@@ -27,6 +27,8 @@ typedef struct
FIXED rotation;
FIXED vrotation;
bool selected;
bool focused;
} SpriteObject;
// Sprite methods
@@ -58,6 +60,7 @@ void sprite_object_shake(SpriteObject* sprite_object, mm_word sound_id);
void sprite_object_set_selected(SpriteObject* sprite_object, bool selected);
bool sprite_object_is_selected(SpriteObject* sprite_object);
Sprite* sprite_object_get_sprite(SpriteObject* sprite_object);
void sprite_object_set_focus(SpriteObject* sprite_object, bool focus);
bool sprite_object_is_focused(SpriteObject* sprite_object);
#endif // SPRITE_H