Commit Graph

432 Commits

Author SHA1 Message Date
Geralt d5d5a6fd6b Refactor/shop (#475)
* initial commit, DOES NOT COMPILE

* Rename joker interactions file to `joker_row`

* IT'S WORKIIING (now to make it pretty lol)

* fixed rebase issues

* fix rebase + undo state machine changes

* Document shop state functions

* clang format

* fix reroll cost not appearing on shop init

* Move generic SpriteObject text/price printing functions to sprite.c + some minor fixes

* Resolve weird defines/include order issue

* clang format

* Implement suggestions from @ricfehr3

* clang format

* clang format

* fix rebase

* Implement sugegstions from @ricfehr3

* Refactored shop to use the Button struct

* missed some memsets

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
2026-05-15 18:36:19 -07:00
Rickey b1c2b7f35e Refactor/round end (#479)
* Initial round_end extraction

* move hands to game vars

* Checkpoint

* Finish removing all variables for state fns

* Move over round_end substate functions

* Move over round_end with compile

* working in general

* Fix round start state issue

* clang-format

* Fix clang format issue

* PR fixes and standardize types in game vars struct

* Clang-format
2026-05-13 18:22:02 -07:00
Geralt a79c4c92e2 Updating the save mechanism by creating an intermediary SaveData struct (#472)
* Make save changes their own branch

* Make SaveData tags char[] instead of u32[]

* Make Game and Options data saving independent

* removed unused functions

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* mark save sections as valid only after they are actually written to SRAM

* fix comparison between different integer types

* Implement some suggestions from @ricfehr3

* Add extensive documentation on the structure of the savefile

* fix doxygen doc generation

* fix it again

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-10 12:39:54 -07:00
Geralt 6373fee144 Refactor/game over screen (#468)
* Move game over (win/lose) state functions to their own file

* remove unused enum

* clang format

* Implement suggestions from @ricfehr3

* Fixing lack of highlighted button after skipping  ablind

* factorize as much game over state code as possible

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
2026-05-07 21:36:12 -07:00
Rickey d01b1ba12d Refactor/blind select screen (#461)
Refactor Blind Select Screen.

Based on #363
---------

Co-authored-by: emiyl <me@emiyl.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-06 00:56:59 -07:00
Geralt 8e5295814f commit (#459)
Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
2026-05-02 14:39:49 -07:00
Geralt e7f550ce22 [Feature] Implement options menu and reading/writing values from/to the SRAM (#449)
* background

* Implement Options button

* Update main menu artwork

* add options menu tiles

* prepare options menu handling

* incorporate main menu refactor

* toto

* add all menu interactions

* do not reset selection_x in main_menu

* options struct

* fix rebase from ricfehr3's repo

* Implement high contrast cards

* Save/Load options values to SRAM

* load options on game_init and validate data within the load_options function

* Get changes from ricfehr3's PR

* recover fix for glitched ace

* clang format

* clang format

* clang format

* Save 500B of image data by using only minimal set of tiles instead of keeping final window in source file

* clang format

* clang format

* Implement Options button

* Update main menu artwork

* progress, leaving it alone for now until discussion

* make game_vars an extern

* Move options vars into their own struct

* rollback previous commit

* Implement save validation. Version check to come

* implement data validity + version check for game saves

* clang format

* Save position in rng sequence for consistent run after load

* fix rebase issues

* fix rebase issue

* remove unused/duplicate define

* Oops, made a mistake when testing PR #424

* encode high contrast palette into an image, and load it at game_start

* document save.c/h and correct typos

* correct alignment

* game speed and high contrast buttons working

* small cleanup

* sliders also work again now

* clang format

* Moved balatro_version extern declaration to version.h file

* removed unsused variable

* make showing ROM version a toggle

* move ante, round and money to the GameVariables struct

* Rename SaveCheckInfo struct to SaveHeader for clarity

* Add SaveHeader struct explanation

* clang format

* Revert unnecessary tileset optimization

* SFX now follows the sound volume slider

* clang format

* Music now follows volume slider

* Changed volume slider increment from 5 to 20 to avoid having the music sound too rough under 20% volume

* refactor main_menu.c to use SelectionGrid and Button structs

* clang format

* make a "new" save button so we don't save during the state transition

* clang format

* Reduced state transition flicker by only changing affine background to a different one

* Fix loading game too late in game init sequence

* First batch of suggestions from @MeirGavish

* Remove unnecessary intermediary buffers for high contrast palette swapping

* comment row warp hack for button input

* Add some of Copilot's suggestions

* rename balatro_version into gbalatro_version for rebranding reasons + version display erase screen fix

* remove unnecessary NULL check on `on_selection_changed` method

* implement small game speed arrow buttons animation

* factorize some code

* remove unnecessary data validation in load_game(), since we already checked the header

* Implement @MeirGavish 's suggestion regarding splitting the huge `on_update` function

* clang format

* implement @ricfehr3 's suggestion about keeping last selected button instead of using an obscure `on_boot` boolean

* Apply @ricfehr3's suggestions

* fix clang-format flags

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
2026-05-02 14:28:52 -07:00
Rickey da988ba7f5 Refactor/main menu (#416)
* Add basic common_ui background gfx functions

* Move game main menu to separate file

* clang format

* tmp commit basic docs

* clang format

* scope vars and cleanup

* Quick consistency update. Finalize.

This branch is based on: https://github.com/GBALATRO/balatro-gba/pull/363
Co-authored-by: emiyl <me@emiyl.com>

* Simplify global struct

* clang-format

* Add clang-format to subdirs

* Move timer definitions into their own file

* clang-format

* Fix action yml

* docs

* Update for PR

* Move game start to a state

* Remove lag switch

* Remove GameVariables pointer for callbacks

* Make game_vars a global

* move declaration of game vars in header

* Fix multiple game_vars

* fix for pr

* remove change_background in update again

* clang format

* Make bgCallbacks table static const

---------

Co-authored-by: emiyl <me@emiyl.com>
2026-04-27 20:04:18 -07:00
Rickey adca0961f5 Refactor/make game vars extern (#451)
* Remove GameVariables pointer for callbacks

* Make game_vars a global

* move declaration of game vars in header

* Move g_game_vars location
2026-04-27 19:55:07 -07:00
Elliot Tester 35b6169fd7 Optimize Damping Coefficient (#444)
* Optimize Damping Coefficient

* Added Rounding + Moved Constants

* Added Comments and Made Rounding not use a magic number

* adjust epsilon

* Adjusted Documentation
2026-04-23 19:17:23 +03:00
MeirGavish a3ef7b1493 Fixed blind sprite flip issue by removing affine attribute (#439) 2026-04-17 19:45:45 +03:00
Geralt db27962623 Implement boss blind graphics (#352)
* Created sprite bank for all blinds

* progress city, it's a beatiful city that progress city!

* Sprite appears in blind selection screen

* Added all blind colors

* fix magic numbers + disable boss reroll

* Fix boss blind token not moving after a reroll

* fix always rolling the Needle due to choosing too early for the rng seed to be set

* No need for affine sprite for blind tokens, regular is enough

* address Copilot's review 1/2

* address Copilot's review 2/2

* correct Blind Tokens/Types

* Index palette colors into the files instead of code

* Fix blind sprites (flip bug not solved)

* Fix magic number, tile index and Mark colors

* load boss blind palette only when changing spritesheet

* Adressing clang format and ease of modification of the blinds' list

* Removed some magic numbers


---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
2026-04-16 11:52:39 +03:00
Umut Paklacı 1e1394ec21 Fix shop reroll button's horizontal movement (#316) (#425)
* Add optional exit indexes to selection grid rows & fix shop reroll button movement (#316)

- Added has_exit_idx and exit_idx to SelGridRowAttributes to simulate subgrid-like behavior that was desired in shop reroll button
- Add logic to use exit index if given inside selection_grid_move_selection_horz()
- Add joker focus logic to shop_reroll_row_on_selection_changed()

* clang-format fix

* clang format fix #2

errors due to version mismatch in local fixed (i hope)

* important fix: check x instead of y for next_roudn_btn_sel_x

was checking y against an X value

* changed commenting

* selection_grid.h clang-format fix

* changed commenting again

trying to make docs understandable

* set shop selection rows explicit

Co-authored-by: Rickey <ric@rf3.xyz>

* syntax fix

* clang format fix onceagain

* guard clause when moving down from jokers

---------

Co-authored-by: Rickey <ric@rf3.xyz>
2026-04-05 23:19:08 -07:00
Rickey f46395b9d0 Add basic common_ui background gfx functions (#415)
* Add basic common_ui background gfx functions

* clang format

* document common_ui.h

* Remove unused tonc header

* Fix header guard name convention

* more header cleanup

* claaaaanggggg format
2026-03-31 21:04:47 -07:00
MeirGavish 18f70714ce Increased number of audio channels to 14 (#409) 2026-03-29 20:04:25 -07:00
Elliot Tester ff2c792a3b Corrected Sprite Indices for Droll and Crafty Jokers (#413) 2026-03-29 15:09:35 -07:00
Rickey 835e44e4db Introduce the game variables struct (#338)
Co-authored-by: emiyl <me@emiyl.com>

* Introduce the game variables struct

* Fix clang format

* Move game variables into their own file
2026-03-29 14:32:21 -07:00
Geralt 5cf9e2674d Implement arbitrary-sized joker spritesheets (#285)
* Convert static joker sprites indexes to maps for dynamic spritesheets size

* tmp commit

* reorder Joker spritesheets

* more reordering

* Joker maps, will test later

* More reorders and palette optimizations. Sprites now work

* Fix Joker gfx

* Format joker.c

* Fix rebase error

* Integrate Shoot the Moon art

* format

* format

* removing useless GBAL_UNUSED from photograph Joker effect func

* Tidy up joker.c variables formatting

* Fix magic number

* Add context for map in joker.c

Co-authored-by: Rickey <ric@rf3.xyz>

* Update source/joker.c

Co-authored-by: Rickey <ric@rf3.xyz>

* Apply suggestion from @ricfehr3

Co-authored-by: Rickey <ric@rf3.xyz>

* format

* reduce clutter in joker_effects.c file by defining a macro for forward static declarations of joker effect funcs

* refactored some maps in joker.c to make it more concise

* clang format

* adding back how to mark functions as unused when Jokers don't have a sprite yet

* format

* Remove comment about unused functions for Jokers without art

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
Co-authored-by: Rickey <ric@rf3.xyz>
2026-03-28 17:58:05 -07:00
MeirGavish 1d71be674d Changed the capitalization of hand names and centered them (#391) 2026-03-08 15:31:19 +02:00
MeirGavish 45b2275b68 Fixed round counter not resetting on game over + removed unused variable (#394)
* Fixed round not resetting on game over + removed unused variable
2026-03-07 11:45:49 +02:00
Rickey 0bc140b4e8 Document sprite.h w/ minor optimizations / fixes (#379)
* Rename Sprite to SpriteInfo

---------

Co-authored-by: MeirGavish <meir.gavish@gmail.com>
2026-02-11 16:55:56 +02:00
MeirGavish b292d227f9 Fix round start top left blind panel animation background (#377)
* Refactored helper sides copying code in expand 3x3 code

* Implemented main_bg_se_copy_expand_3w_row()

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-31 08:13:54 +02:00
MeirGavish 0f9ebd56f6 Changed L and R keys to play and discard respectively (#374)
* Changed L and R keys to play and discard respectively, removed sorting key in favor of on-screen buttons

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-28 19:08:47 +02:00
Geralt fe4820cf65 Fix cards in deck count shifting when too few cards remain (#370)
* fix

* fix deck size/max size text not getting erased

* add TODO for future deck size overflow fix

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
2026-01-26 09:22:20 +02:00
Geralt 339d8dc79f Fix selecting a card by accident when moving too fast on round start (#369)
* fix bug

* make timers ints instead of uints

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
2026-01-26 05:36:31 +02:00
MeirGavish 97bf8b3efd Added sort by rank/suit buttons (#351)
* Added definitions for sorting buttons (cherry pick, does not compile)

* Re-applied changes lost in merge

* Added sort buttons functionality (cherry-pick, has issues)

* Fixed sort buttons issue

* Removed stray code from merge

* clang-format

* Removed code from merge error

* Removed unused function from merge error

* Removed "E" typo from "SUIT" button

* Changed all the 2x5 S's in the UI to be 1 pixel wider at 3x5

* Revert "Changed all the 2x5 S's in the UI to be 1 pixel wider at 3x5"

This reverts commit f70e0d5ab76dd851c564672c01ab60cd25c28b63.

* Changed the width of the "SUIT" button to be consistent with the "RANK" button
2026-01-24 10:06:51 +02:00
Geralt 02799ddc54 Optimize "whole hand" conditions checks for Joker effects (#213)
* Introduce a ContainedHandTypes type

* Separate computing of hand_type and _contained_hand_types variables

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
2026-01-22 14:22:48 +02:00
Emma fc5767c96e Reset selection_y after blind skip (#362) 2026-01-16 08:11:47 +02:00
MeirGavish 5300846f73 Refactored to use selection grid during round (#348)
* Added wrapping to selection grid

* Added return value to on_selection_changed to allow aborting on wrap

* Extracted button code to button.c/.h

* Bounds checking changes for selection_grid_move_selection_horz()

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Rickey <ric@rf3.xyz>
2026-01-15 20:32:09 +02:00
MeirGavish b7cc3ec5d6 [Optimization] Slow score lerping from 60 to 30 FPS (#336) 2026-01-14 16:43:53 -08:00
Horváth Balázs 11dafe26ac Fix Four Fingers joker effect persisting after game over (#359)
* Fix four fingers joker effect stuck after game over

* Fix game_over_on_exit() not removing owned jokers
2026-01-11 23:18:40 +02:00
MeirGavish db9879b5b5 Added blind score requirement and reward in blind select screen (#282)
* Added blind select requirement and rewards printing

* Broke game_blind_select_print_blinds_reqs_and_rewards() into separate functions
2026-01-06 11:06:24 +02:00
MeirGavish 34889988a9 Added documentation to get_played/hand_distribution (#343)
* Added documentation to get_played/hand_distribution

* Documented get_played_distribution() behavior
2025-12-28 11:20:30 -08:00
MeirGavish 6575fc7f94 Update the truncate number function to use decimal point (#333)
* Fixed to truncate as "1.234M" instead of "1234K"

* Optimized by switching to strings to avoid divisions

* Changed FP constants to strings

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-23 07:52:30 +02:00
MeirGavish f76c25614c Change selection grid to maintain relative horizontal position when switching rows (#329)
* Change selection grid to maintain relative horizontal position when switching rows

* clang-format

* Fixed joker selling index error

* Protect against division by 0 and removed redundant fixed point conversions.
2025-12-21 22:00:08 -08:00
Rickey 628c0c992d Introduce decimal point font (#314)
* Introduce decimal point font

* Add png of font

* Add getting a decimal point str from int

* Move font out of utils

* Clang format

* set Readme.md as main page in docs

* Add font generator

* kind of fix font

* Fix image oddities

* Added pip install pillow to build_ci_workflow

* Added ensurepip

* Update Docker/CI for font generation

* Fix CI

* Fix CI forreal

* Another CI fix

* Fix directory name for rom

* Adjust directory

* Dummy commit for test

* Revert "Dummy commit for test"

This reverts commit b607085c1322c824d2fdd800ab3c3700389ad3a6.

* dos2unix and update .gitignore

* Delete the generated font file

* Delete the generated font file

* remove dot from font

* Update include/font.h

Co-authored-by: MeirGavish <meir.gavish@gmail.com>

---------

Co-authored-by: MeirGavish <meir.gavish@gmail.com>
2025-12-18 18:19:01 -08:00
Geralt faa75a4eea Swap Cards in Hand (#280)
* card sorting

* Added refactor from @MeirGavish

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-18 15:14:28 +02:00
Copilot b146bb667b Add parentheses to timer macro expressions (#319)
---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MeirGavish <34395426+MeirGavish@users.noreply.github.com>
2025-12-16 11:43:07 +02:00
MeirGavish e90f23661d Sound effects for score accumulation and blind menu pop-up (#313) 2025-12-16 10:32:04 +02:00
MeirGavish 177a3a9741 Fixed bug where the mult wasn't truncated (#315) 2025-12-16 09:53:50 +02:00
MeirGavish f095bf7024 Added documentation for selection_grid.h (#309)
* Added documentation for selection_grid.h

* Fix clang-format

* Update include/selection_grid.h

Co-authored-by: Rickey <ric@rf3.xyz>

* Added NULL-checks for selection_grid_move_selection_horz/vert()

---------

Co-authored-by: Rickey <ric@rf3.xyz>
2025-12-15 21:16:25 -08:00
MeirGavish 81e6b7ab31 Button sound effect (#312)
* Removed magic number for CARD_FOCUS_SFX_PITCH_OFFSET_RANGE
2025-12-13 16:10:15 +02:00
MeirGavish 8a9750b0b3 Used proper text centering for price printing and consolidated functions for printing and erasing (#308) 2025-12-13 09:03:06 +02:00
MeirGavish 9bffe5c9a9 Refactor - remove selected from SpriteObject (#305) 2025-12-12 18:44:26 -08:00
MeirGavish 16b24a0bf9 Updated splash screen with new organization URL (#306) 2025-12-10 23:00:46 -08:00
Marcel Schulz f9ed858549 [Fixed] Joker shop price not properly erased on purchase (#286) 2025-12-11 08:39:09 +02:00
MeirGavish d96bc9b1c2 Renamed GBLA_UNUSED -> GBAL_UNUSED and updated RowOnKeyTransitFunc documentation (#292) 2025-12-10 17:17:28 -08:00
MeirGavish 5a4856ec82 Refactor - removed tile_mem obj charblock index magic number (#293) 2025-12-10 17:13:59 -08:00
Rickey 2fb9e6d633 Clang format joker files and def files (#257)
* Clang format joker files and def files

* Fix blind usage of GBLA_UNUSED macro

* Add final files for clang-format (main.c and selection_grid.h)

---------

Co-authored-by: MeirGavish <meir.gavish@gmail.com>
2025-12-10 09:41:24 +02:00
Rickey 35ecbf33ae Format and document utility files (#246)
* Format and document utility files

* Add Doxyfile

* small updates for cleanup

* Final touches for util docs

* Replace `_` with `s_` for static functions

* update for clang-format changes

* Update include/audio_utils.h

Co-authored-by: MeirGavish <meir.gavish@gmail.com>

* Apply suggestions from code review

Co-authored-by: MeirGavish <meir.gavish@gmail.com>

* Update include/audio_utils.h

Co-authored-by: MeirGavish <meir.gavish@gmail.com>

* Update include/graphic_utils.h

Co-authored-by: MeirGavish <meir.gavish@gmail.com>

* Make clang-format happy :)

* Update gitignore for doxygen

* restor graphic_utils.c to main

* update graphics utils

* tmp

* tmp

* get it to compile

* fix some bad merge mistakes

* Fix clang format

* Apply suggestions from code review

Co-authored-by: MeirGavish <meir.gavish@gmail.com>

* make clang-format happy

---------

Co-authored-by: MeirGavish <meir.gavish@gmail.com>
2025-12-07 12:56:39 -08:00