Clang format and refactor game.h/c + update Bracket Alignment to BlockIndent (#259)
* Refactor and clang-format game.h/c * Updated clang-format AlignAfterOpenBracket: BlockIndent and ColumnLimit: 100 and refactored all files accordingly --------- Co-authored-by: MeirGavish <meir.gavish@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
MeirGavish
Copilot
parent
43d837571e
commit
291edaf4f2
+7
-5
@@ -34,10 +34,11 @@ int bitset_set_next_free_idx(Bitset* bitset)
|
||||
// https://gcc.gnu.org/onlinedocs/gcc/Bit-Operation-Builtins.html#index-_005f_005fbuiltin_005fctz
|
||||
//
|
||||
// By using the bitwise inverse of the word, you can skip words that are full
|
||||
// quickly (where the value is 0 or 'false' since all bits are '1', or 'in use'). Any value greater
|
||||
// than 0 indicates there is a free slot. Then, when counting the trailing 0's, you can test very quickly
|
||||
// where the first free slot is. This operation prevents looping through every bit of filled flags, and
|
||||
// will instead operate only on the first word with free slots.
|
||||
// quickly (where the value is 0 or 'false' since all bits are '1', or 'in use'). Any value
|
||||
// greater than 0 indicates there is a free slot. Then, when counting the trailing 0's, you
|
||||
// can test very quickly where the first free slot is. This operation prevents looping
|
||||
// through every bit of filled flags, and will instead operate only on the first word with
|
||||
// free slots.
|
||||
if (inv)
|
||||
{
|
||||
int bit = __builtin_ctz(inv);
|
||||
@@ -100,7 +101,8 @@ int bitset_find_idx_of_nth_set(const Bitset* bitset, int n)
|
||||
if (tracker > n)
|
||||
{
|
||||
// The index is here somewhere
|
||||
// this one is to count the 1's not the offset, underflow to -1 is good for finding the 0 index
|
||||
// this one is to count the 1's not the offset, underflow to -1 is good for finding the
|
||||
// 0 index
|
||||
int base = prev_tracker - 1;
|
||||
// this one is for the actual offset we want to map the id to
|
||||
int offset = bitset->nbits * i;
|
||||
|
||||
+15
-6
@@ -10,7 +10,8 @@
|
||||
#include "pool.h"
|
||||
#include "soundbank.h"
|
||||
|
||||
// Card sprites lookup table. First index is the suit, second index is the rank. The value is the tile index.
|
||||
// Card sprites lookup table. First index is the suit, second index is the rank. The value is the
|
||||
// tile index.
|
||||
const static u16 _card_sprite_lut[NUM_SUITS][NUM_RANKS] = {
|
||||
{0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192},
|
||||
{208, 224, 240, 256, 272, 288, 304, 320, 336, 352, 368, 384, 400},
|
||||
@@ -88,11 +89,19 @@ void card_object_update(CardObject* card_object)
|
||||
void card_object_set_sprite(CardObject* card_object, int layer)
|
||||
{
|
||||
int tile_index = CARD_TID + (layer * CARD_SPRITE_OFFSET);
|
||||
memcpy32(&tile_mem[4][tile_index],
|
||||
&deck_gfxTiles[_card_sprite_lut[card_object->card->suit][card_object->card->rank] * TILE_SIZE],
|
||||
TILE_SIZE * CARD_SPRITE_OFFSET);
|
||||
Sprite* sprite =
|
||||
sprite_new(ATTR0_SQUARE | ATTR0_4BPP | ATTR0_AFF, ATTR1_SIZE_32, tile_index, 0, layer + CARD_STARTING_LAYER);
|
||||
memcpy32(
|
||||
&tile_mem[4][tile_index],
|
||||
&deck_gfxTiles
|
||||
[_card_sprite_lut[card_object->card->suit][card_object->card->rank] * TILE_SIZE],
|
||||
TILE_SIZE * CARD_SPRITE_OFFSET
|
||||
);
|
||||
Sprite* sprite = sprite_new(
|
||||
ATTR0_SQUARE | ATTR0_4BPP | ATTR0_AFF,
|
||||
ATTR1_SIZE_32,
|
||||
tile_index,
|
||||
0,
|
||||
layer + CARD_STARTING_LAYER
|
||||
);
|
||||
sprite_object_set_sprite(card_object->sprite_object, sprite);
|
||||
}
|
||||
|
||||
|
||||
+2437
-1892
File diff suppressed because it is too large
Load Diff
+11
-4
@@ -221,7 +221,8 @@ bool hand_contains_flush(u8* suits)
|
||||
* @param played Array of pointers to CardObject representing played cards.
|
||||
* @param top Index of the top of the played stack.
|
||||
* @param min_len Minimum number of cards required for a flush.
|
||||
* @param out_selection Output array of bools; set to true for cards in the best flush, false otherwise.
|
||||
* @param out_selection Output array of bools; set to true for cards in the best flush, false
|
||||
* otherwise.
|
||||
* @return The number of cards in the best flush found, or 0 if no flush meets min_len.
|
||||
*/
|
||||
int find_flush_in_played_cards(CardObject** played, int top, int min_len, bool* out_selection)
|
||||
@@ -265,9 +266,15 @@ int find_flush_in_played_cards(CardObject** played, int top, int min_len, bool*
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Returns the number of cards in the best straight or 0 if no straight of min_len is found, marks as true them in
|
||||
// out_selection[]. This is mostly from Google Gemini
|
||||
int find_straight_in_played_cards(CardObject** played, int top, bool shortcut_active, int min_len, bool* out_selection)
|
||||
// Returns the number of cards in the best straight or 0 if no straight of min_len is found, marks
|
||||
// as true them in out_selection[]. This is mostly from Google Gemini
|
||||
int find_straight_in_played_cards(
|
||||
CardObject** played,
|
||||
int top,
|
||||
bool shortcut_active,
|
||||
int min_len,
|
||||
bool* out_selection
|
||||
)
|
||||
{
|
||||
if (top < 0)
|
||||
return 0;
|
||||
|
||||
+11
-7
@@ -16,9 +16,11 @@ void splash_screen_on_init()
|
||||
|
||||
tte_printf("#{P:72,8; cx:0xF000}DISCLAIMER");
|
||||
tte_printf(
|
||||
"#{P:8,24; cx:0xF000}This project is NOT endorsed \n by or affiliated with \n Playstack or LocalThunk.\n\n If "
|
||||
"you have paid for this, \n you have been scammed \n and should request a refund \n IMMEDIATELY. \n\n The only "
|
||||
"official place \n to obtain this is from: \n\n 'github.com/\n cellos51/balatro-gba'");
|
||||
"#{P:8,24; cx:0xF000}This project is NOT endorsed \n by or affiliated with \n Playstack or "
|
||||
"LocalThunk.\n\n If you have paid for this, \n you have been scammed \n and should request "
|
||||
"a refund \n IMMEDIATELY. \n\n The only official place \n to obtain this is from: \n\n "
|
||||
"'github.com/\n cellos51/balatro-gba'"
|
||||
);
|
||||
tte_printf("#{P:8,144; cx:0xF000}(Press any key to skip)");
|
||||
}
|
||||
|
||||
@@ -29,10 +31,12 @@ void splash_screen_on_update()
|
||||
if (timer < SPLASH_DURATION_FRAMES)
|
||||
{
|
||||
tte_erase_rect_wrapper(COUNTDOWN_TIMER_RECT);
|
||||
tte_printf("#{P:%d,%d; cx:0xF000}%d",
|
||||
COUNTDOWN_TIMER_RECT.left,
|
||||
COUNTDOWN_TIMER_RECT.top,
|
||||
1 + (SPLASH_DURATION_FRAMES - timer) / SPLASH_FPS);
|
||||
tte_printf(
|
||||
"#{P:%d,%d; cx:0xF000}%d",
|
||||
COUNTDOWN_TIMER_RECT.left,
|
||||
COUNTDOWN_TIMER_RECT.top,
|
||||
1 + (SPLASH_DURATION_FRAMES - timer) / SPLASH_FPS
|
||||
);
|
||||
|
||||
if (!key_hit(KEY_ANY))
|
||||
{
|
||||
|
||||
+11
-7
@@ -181,8 +181,8 @@ void sprite_object_update(SpriteObject* sprite_object)
|
||||
|
||||
// set velocity to 0 if it's close enough to the target
|
||||
const FIXED epsilon = float2fx(0.01f);
|
||||
if (sprite_object->vx < epsilon && sprite_object->vx > -epsilon && sprite_object->vy < epsilon &&
|
||||
sprite_object->vy > -epsilon)
|
||||
if (sprite_object->vx < epsilon && sprite_object->vx > -epsilon &&
|
||||
sprite_object->vy < epsilon && sprite_object->vy > -epsilon)
|
||||
{
|
||||
sprite_object->vx = 0;
|
||||
sprite_object->vy = 0;
|
||||
@@ -215,7 +215,8 @@ void sprite_object_update(SpriteObject* sprite_object)
|
||||
if (sprite_object->vrotation < epsilon && sprite_object->vrotation > -epsilon)
|
||||
{
|
||||
sprite_object->vrotation = 0;
|
||||
sprite_object->rotation = sprite_object->trotation; // Set the rotation to the target rotation
|
||||
// Set the rotation to the target rotation
|
||||
sprite_object->rotation = sprite_object->trotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -223,10 +224,13 @@ void sprite_object_update(SpriteObject* sprite_object)
|
||||
sprite_object->rotation += sprite_object->vrotation;
|
||||
}
|
||||
|
||||
obj_aff_rotscale(sprite_object->sprite->aff,
|
||||
sprite_object->scale,
|
||||
sprite_object->scale,
|
||||
-sprite_object->vx + sprite_object->rotation); // Apply rotation and scale to the sprite
|
||||
// Apply rotation and scale to the sprite
|
||||
obj_aff_rotscale(
|
||||
sprite_object->sprite->aff,
|
||||
sprite_object->scale,
|
||||
sprite_object->scale,
|
||||
-sprite_object->vx + sprite_object->rotation
|
||||
);
|
||||
sprite_position(sprite_object->sprite, fx2int(sprite_object->x), fx2int(sprite_object->y));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user