Commit Graph

46 Commits

Author SHA1 Message Date
MeirGavish
8c57f57f1a Removed prefix from macro names 2026-09-04 18:47:40 +03:00
MeirGavish
298e46e273 Added RET_NONE define, removed void macros and replaced all usages with ret versions 2026-09-04 18:22:57 +03:00
MeirGavish
6014191f23 Fixed build errors from rebase 2026-09-04 18:22:57 +03:00
MeirGavish
91104a6898 Added generic assert - WIP 2026-09-04 18:22:55 +03:00
Geralt
0eb7042468 [Bug] Implement independent RNG sequences to avoid interferences (#599)
Some checks failed
Build and Deploy Doxygen Docs / docs (push) Has been cancelled
Deploy Nightly / Run Build ROM Workflow (push) Has been cancelled
Deploy Nightly / Deploy nightly (push) Has been cancelled
* Implement our own Xorshift32 RNG algo to manage independent number sequences

* Fix issues with seed 0

* adress @MeirGavish's review

* Apply suggestions from @MeirGavish's code review

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

* adress the rest of @MeirGavish's review

* adress @MeirGavish's review

* Fix last issues

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
Co-authored-by: MeirGavish <meir.gavish@gmail.com>
Co-authored-by: MonteCrysto <monte.crysto31@gmail.com>
2026-08-05 12:37:06 +03:00
MeirGavish
451f4bd073 Add mode field to Sprite (#563)
Some checks failed
Build and Deploy Doxygen Docs / docs (push) Has been cancelled
* Added sprite_hide and sprite_object_hide functions

* Changed calls to obj_unhide to sprite_unhide

* Fix embarrasing errors

* clang-format...?

* Imported renames from #557

* Removed last uses of obj_hide in round

* Added documentation

* Changed Sprite.idx from int to s16

* Added proper NULL-check macro usage in sprite.c
2026-08-02 13:29:20 +03:00
MeirGavish
6ff55992e7 Removed call to obj_aff_copy() from sprite_draw() (#597)
Some checks failed
Build and Deploy Doxygen Docs / docs (push) Has been cancelled
2026-07-23 20:09:34 -07:00
MeirGavish
d24b0b5619 Refactor shop code to use generic Item (#536)
Some checks failed
Build and Deploy Doxygen Docs / docs (push) Has been cancelled
* Turned SpriteObject into a member of JokerObject and CardObject and expiremented with casting

* Extracted shop code to use generic `SpriteObject`

* Extracted shop joker generation to a function

* Renamed object -> item

* Added setters and getters for `SpriteObject` members and updated all accesses to use them with casting (AI used for tedious work and reviewed - model Raptor mini)

* Added sprite_object_set_vx() because sprite_object_set_vy() exists and reordered the function order to have x,y parameters first, then targets

* Added Item object to act as a purchasable interface for the shop - AI used (model Raptor mini)

* Added -fms-extensions and switched to anonymous inheritance

* Fixed anonymous inheritance for joker and added direct access for that too

* fix build error from previous commit + clang-format

* Fixed build errors + clang-format for real this time (I hope...)

* clang-format one last time, I don't understand it anymore

* clang-format is annoying

* Added uses of CHECK_NULL_ARG macros

* Merged item_defs.h into item.h and fixed build error from previous commit

* clang-format...?

* Changed sprite_object_new() into sprite_object_init() and made it accept a parameter instead of returning one to make it less awkward

* Updated sprite_object_init() documentation

* Updated sprite_object_destroy documentation

* More clang-format

* Renamed add_to_inventory to acquire and updated documentation

* Added function documentations

* Update documentation + swap order of consumable and playing card types

* Added documentation for new files (+ small addition to button.h)

* clang-format

* Used typedef

* A bit more documentation

* Changed sho pcode to use generic Item instead of SpriteObject

* clang-format + fixed NULL-check error

* Revert weird clang-format...?

* clang-format for real

* Fixed errors from rebase on log_function_name

* Fixed build errors from rebase on main

* Added some more documentation about first member struct inheritance

* typo fix

* typo fix for real

* Removed SpriteObject field getters/setters (AI used - model Raptor mini)

* Renamed item_acquire -> item_on_acquired

* Added item_can_acquire()

* clang-format

* Fixed some sprite issues but not all...

* Fixed some more issues

* Cleanup JokerObject some more JokerObjects in the shop

* Added `item_destroy()`

* Added item_set_available_to_shop, CHECK_ITEM_TYPE macros + small documentation updates

* Another small JokerObject->Item replacement

* Removed item_set_available_to_shop and replaced with item_roll_new() and item_dispose(), also changed "available_to_shop" semantics to "rollable"

* Re-applied changes from game.c to round.c after rebase on main

* Added partial implementations of item functions for playing cards

* Line endings fix...

* Macro renames, function documentations

* Updated documentations

* Apply fixes from Copilot review

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

* Fix card_object_get_buy_price type checking

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

* Avoid double pointer cast on dispose

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

* Apply suggestions from @ricfehr3's code review

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

* Remove redundant comments

* Moved error checking before joker_get_random_rarity

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

* Fixed build error from rebase

* clang-format

* Added doxygen documentation for Item explaining inheritance

* Removed unnecessary comment

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Rickey <ric@rf3.xyz>
2026-07-09 09:13:51 +03:00
Geralt
c706a387a9 Implement a global SpriteObject update loop (#553)
Some checks failed
Build and Deploy Doxygen Docs / docs (push) Has been cancelled
* Implement `sprite_object_update_all`

* clang format

* Change update order

* tmp

* make it crash

* Fix bad address crash

* Address @MeirGavish's comments

* Tweaked card draw position further

* Tweaked card draw position further, again

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
2026-06-17 19:26:53 -07:00
Geralt
751a547059 Implement new sprite_object_position function (#559)
Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
2026-06-16 20:33:31 +03:00
Rickey
8111b6e046 Cleanup sprite_position usage (#539)
Some checks are pending
Build and Deploy Doxygen Docs / docs (push) Waiting to run
* Cleanup sprite_position usage

* Add IWRAM_CODE attr for inline sprite function

* removed extra sprite_position call
2026-06-11 18:01:41 -07:00
Geralt
c2844a5d32 Refactor/RNG system (#476)
* Extract rng manipulation to its own file

* clang format

* Get CPU cycles since game start to use for RNG

* change a few things

* clang format

* Implement suggestions from @ricfehr3

* clang format

* Fix rebase issue

* clang format

* Create RngInfo struct to hold seed and step

* clang format

* Make a note about rng_restore system not having been tested properly yet

* Apply suggestions from @ricfehr3

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

* clang format

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
Co-authored-by: Rickey <ric@rf3.xyz>
2026-05-21 19:47:48 -07:00
Elliot Tester
dae65d035f sprite optimizations + static array fix (#454)
Some checks failed
Build and Deploy Doxygen Docs / docs (push) Has been cancelled
* optimizations

* fix prototype

* clang-format

* changes

* fix bug

* fix bug that came back after rebase

* make is_sprite_object_static more readable

* make it not broken

* actually make it compile...

* clang-format

* remove first extra check

* remove second extra check

* remove third extra check

* helper function 1

* second helper function

* how did i do this that wrong

* seperate epsilon

* combine if statements

* clarify comment

* remove redundant checks

* Remove braces around return

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

* Move comment to above

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

* clang-format

* simplify using abs()

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

* fix syntax error from suggestion

* drop second epsilon + use abs()

* update comment

* extract sprite_oject_needs_position_sync from is_sprite_object_static

* figured out the root cause :)

* make it compile

---------

Co-authored-by: Rickey <ric@rf3.xyz>
2026-05-16 21:08:47 -07:00
Geralt
d5d5a6fd6b Refactor/shop (#475)
Some checks are pending
Build and Deploy Doxygen Docs / docs (push) Waiting to run
* 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
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
Elliot Tester
35b6169fd7 Optimize Damping Coefficient (#444)
Some checks failed
Build and Deploy Doxygen Docs / docs (push) Has been cancelled
* 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
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
81e6b7ab31 Button sound effect (#312)
* Removed magic number for CARD_FOCUS_SFX_PITCH_OFFSET_RANGE
2025-12-13 16:10:15 +02:00
MeirGavish
9bffe5c9a9 Refactor - remove selected from SpriteObject (#305) 2025-12-12 18:44:26 -08:00
Marcel Schulz
f9ed858549 [Fixed] Joker shop price not properly erased on purchase (#286) 2025-12-11 08:39:09 +02:00
Rickey
291edaf4f2 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>
2025-12-03 13:49:31 +02:00
Rickey
6db35b0f95 Clang format sprite (#262) 2025-11-24 23:26:47 +02:00
Rickey Fehr
517d40c294 Cleanup for PR, return old sprite tracker 2025-10-19 15:52:36 -07:00
Rickey Fehr
16059ab632 Update for PR
Readd sprite tracker to not reuse indices
check for capacity when returning pool entries
Update script for printing memory map
2025-10-17 16:55:09 -07:00
Rickey Fehr
06cd13a17f Centralize location of memory pools
This commit centralizes the location of memory pools and adds an
associated script (scripts/get_memory_map.sh) to read the memory map.
2025-10-17 16:55:09 -07:00
Rickey Fehr
72c0a6c4a9 Optimize bit operations, style fix, cleanup 2025-10-17 16:55:07 -07:00
Rickey Fehr
e00c51502b Replace Malloc With Pools
This commit introduces an object pool and replaces instances of malloc with pools where sensible.
2025-10-17 16:54:09 -07:00
alex
d108836b6a changed how game_speed affects hand score animations 2025-10-13 20:24:20 -07:00
alex
daba462575 fixed a division thingy 2025-09-23 12:45:09 -07:00
alex
ad9358547d main 2025-09-23 12:44:03 -07:00
alex
f57c37b900 fixed a divison thingy 2025-09-23 12:40:26 -07:00
alex
7bafc260dd fixed game_speed, now using fixed point and keeping game_speed static 2025-09-22 22:04:51 -07:00
alex
301f5a2a53 kind of fixed how game_speed behaves 2025-09-21 23:49:24 -07:00
alex
6e60cf5970 kind of fixed how game_speed behaves 2025-09-21 23:16:50 -07:00
Drew
e8e945b17d Removed redundant copy of shadow buffer into OAM. 2025-09-14 13:50:38 -05:00
MeirGavish
64274ae465 Added joker selling (still no animation) + fixed SpriteObject constructor focused bug 2025-08-16 15:38:34 +03:00
MeirGavish
d1677e82d2 Added Selection Grid system and refactored shop code to use it 2025-08-15 19:30:07 +03:00
MeirGavish
06dc4f9c62 Extracted focus to SpriteObject for joker selling - WIP 2025-08-15 10:38:20 +03:00
MeirGavish
0e080b916e Reverted removals of float2fx() as they're compiler-optimized but kept float optimization 2025-08-12 11:40:22 +03:00
MeirGavish
658b0572d9 Removed all uses of float for optimization 2025-08-12 03:01:02 +03:00
MeirGavish
8956501591 Merge branch 'main' into jokers_palette_swapping 2025-08-04 10:21:19 +03:00
MeirGavish
de672572b1 Updated joker palette swapping system to reuse palettes when jokers are removed 2025-08-04 10:18:33 +03:00
MeirGavish
a8f429eca3 Moved the price of shop items below the item so it is not obstructed when the card is raised on highlight 2025-08-03 16:08:41 +03:00
MeirGavish
95565862b0 Extracted JokerObject and CardObject common functionalities to SpriteObject, removing duplicate code and dangerous casts. 2025-07-27 01:13:57 +03:00
cellos51
176910c483 Jokers appear in the shop but don't do anything yet 2025-07-18 19:29:17 -04:00
cellos51
cac321a325 first commit 2025-01-31 17:42:09 -05:00