Commit Graph

61 Commits

Author SHA1 Message Date
MeirGavish d24b0b5619 Refactor shop code to use generic Item (#536)
* 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 45eac259a5 [Refactor] Separate Round logic into its own file (#570)
* Everything works, need to clean up

* cleanup

* fix rebase issue

* clang format

* docs

* clang format

* clang format

* address part of review

* Protect against edge case when discarding at end of hand

* Protect undiscard against popping a discarded card that doesn't exist

* Protect against out of bounds access to the `played` cards stack

* fix condition in `select_four_of_a_kind_cards_in_played_hand`

* change `get_played_top() + 1` to `get_played_size()`

* move `can_play/discard_hand` functions to round.c

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
2026-06-27 16:57:37 -07:00
Geralt c706a387a9 Implement a global SpriteObject update loop (#553)
* 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
MeirGavish 2ea3e7b19c Removed dubious sprite_object cast from long ago (#538) 2026-06-09 19:38:47 -07:00
Geralt e26558e1a5 [Feature] Implement Joker descriptions in the Shop when holding B (#530)
* WIP

* WIP

* WIP

* WIP

* Tags are bugged but it's looking good

* Centering is bugged, almost there

* WIP

* Fixed centeriiiing, yaaaay

* good progress

* add proper '\n' support

* WIP descriptions

* All descriptions are there ^^

* missing 9-patch for pretty display

* WIP

* fix rebase issues

* Fix minor Run Setup screen issues

* Almost done, only one fix to go

* Aaaalmooost doooneeeee

* make desc frame size adaptative

* add rarity color and text

* final cleanup

* clang format

* clang format

* clang format

* clang format

* clang format

* Fix Joker update loop index

* Fix const and Bull description

* Fix unwanted button SFX

* fix tte colors

* Add misprint description

* Fix justified line length computation

* Add safeguards to tag parsing loop

* clang format

* Fix Ante bugged display at boss blind end

* Tweak suit colors

* Final fixes

* Simplified the way we print descriptions

* simplify further

* get rid of weird macro

* Fix Onwed joker price when holding A after showing its description

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
2026-06-08 18:16:37 -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
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
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
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 9bffe5c9a9 Refactor - remove selected from SpriteObject (#305) 2025-12-12 18:44:26 -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
Geralt 0953a430c4 Implement Seltzer and Joker Expiration effect (#252)
* Add Seltzer art

* Implement Joker expiration

* Add exception to copying Jokers + Seltzer message fix

* Move all scoring logic to joker_object_score away from check_and_score_joker_for_event

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
2025-11-30 08:52:42 +02:00
Geralt 435a9a0a1d Refactor JokerEffect scoring (#245)
* Remove usage of memcmp for JokerEffect null check

* Added suggestions from @ricfehr3

* Add suggestions from @MeirGavish


---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
Co-authored-by: MeirGavish <meir.gavish@gmail.com>
2025-11-28 19:03:47 +02:00
MeirGavish f51380c93c Added sound effects for chips, mult, and xmult (#229) 2025-11-22 07:27:43 +02:00
Geralt 408c264e85 Modify blueprint and brainstorm implementation to fix retrigger bug (#244)
---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
2025-11-21 20:09:07 +02:00
Geralt 2fb41e533c Make Chips, Mult and Score unsigned and protect against overflow (#212)
---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
2025-11-20 12:39:15 +02:00
Geralt 4183f563ab Implement cards held in hand effects (#205)
* Adapt existing Jokers to the Held Card mechanic + effect display location

* Add suggestions from @ricfehr3

* Add suggestions from @MeirGavish

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
2025-11-12 13:18:53 +02:00
Rickey e0cffab768 Update list implementation to work with memory pools (#168)
* Introduce indexed list implementation

* Fix CI tests for pool

* Take bitset out of pool

* Replace joker bitset interactions with wrappers

* Add bitset tests

* Add test to gitignore

---------

Co-authored-by: rfehr-idexx <ric-fehr@idexx.com>
2025-11-11 17:56:21 +02:00
Geralt eb815b7820 Refactor of scoring flow, Joker Callbacks and Card Retriggers (#160)
* Remove Baseball Card for now, will have to wait a future PR

* Removed cards held in hand joker scoring stage - should be in another PR

---------

Co-authored-by: MonteCrysto <mathis.martin31@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: MeirGavish <meir.gavish@gmail.com>
2025-11-01 15:50:52 +02:00
JustinL-12 b38433d191 Weight jokers by rarity in the shop (#152)
* Added weight for the rarity of jokers in the shop

* Includes manual conflict resolution

---------

Co-authored-by: JustinL-12 <jlong30@uic.edu>
Co-authored-by: MeirGavish <meir.gavish@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-27 19:18:48 +02:00
Rickey Fehr 517d40c294 Cleanup for PR, return old sprite tracker 2025-10-19 15:52:36 -07:00
Rickey Fehr d499abe2c4 Cleanup for PR 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
MonteCrysto 8cd86f1640 Merge remote-tracking branch 'upstream/main'
And add NULL Acrobat Joker effect
2025-10-07 20:18:41 +02:00
Drew e620697917 Renamed joker_table.h to def_joker_gfx_table.h. Removed an unnecessary constant 2025-09-22 16:06:45 -05:00
Drew 7c377fca94 Making joker_gfxTiles and joker_gfxPal static 2025-09-17 15:35:21 -05:00
Drew c4e804234b Moving macro into pool definition 2025-09-17 15:01:26 -05:00
Drew 3dc959c17d Converting joker_gfxTiles and joker_gfxPal to pools 2025-09-17 14:35:00 -05:00
Drew 2c5bc3b5dd Adding an x macro to cut down on some boilerplate.
This should make adding additional jokers require a little less
typing. Additional jokers will need an entry in /include/joker_table.h
2025-09-15 21:36:20 -05:00
MeirGavish 2d50005e30 Added art for Scary Face and Smiley Face by @GreenNinja2525 and enabled them in code 2025-08-22 19:43:27 +03:00
MeirGavish 46141090a0 Added joker sprites by @GreenNinja2525 for Blue Joker, Even Steven, Odd Todd, Scholar and Business Card. Disabled jokers with no sprites. 2025-08-17 12:36:20 +03:00
MeirGavish 64274ae465 Added joker selling (still no animation) + fixed SpriteObject constructor focused bug 2025-08-16 15:38:34 +03:00
MeirGavish fd8e52d48a Removed magic numbers for card score length and intmax buffer sizes 2025-08-08 01:59:21 +03:00
MeirGavish 2ce3acbe1c Merge branch 'main' into jokers_with_graphics 2025-08-08 00:32:10 +03:00
theturtlemafia 4492176df2 allows multiple joker-effect popup texts 2025-08-07 23:08:41 +03:00
MeirGavish 50ec1bcdab Added art by @GreenNinja2525 for jokers Walkie-Talkie, Fibonacci, Banner, Mystic Summit, and Blackboard 2025-08-07 23:08:35 +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
theturtlemafia 4731fea21b add joker sprites 2025-08-02 13:08:42 -04:00
theturtlemafia dbff88add0 Adds XMult, Joker Stencil and Misprint (rebase) 2025-08-01 18:35:31 -04:00
MeirGavish 305d093042 Added more joker art by for jokers 6-16, missing code implementation so they are not yet displayed. 2025-08-01 02:03:24 +03:00
MeirGavish 0c834d17c2 Added dynamic palette loading for jokers and added new joker designs by @GreenNinja2525 2025-07-30 21:00:29 +03:00
theturtlemafia ed1204db74 remove usage of extern for joker_registry. Add array size macro to util.h 2025-07-28 14:24:33 -04:00
theturtlemafia 47ee3987fd refactor jokers to use struct and function pointer 2025-07-27 07:06:35 -04: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 6a1f3bcd7a I hope this works 2025-07-23 20:14:22 -04:00
MeirGavish c781807ed8 Revert "Sprite vram optimizations" 2025-07-24 02:14:04 +03:00