From 0f3d1b3b779cece513126dbb542abf055a951865 Mon Sep 17 00:00:00 2001 From: theturtlemafia Date: Fri, 1 Aug 2025 18:22:20 -0400 Subject: [PATCH 1/8] adds walkie-talkie, fibonnaci, banner, mystic summit, blackboard --- include/game.h | 2 ++ source/game.c | 29 ++++++++++++++++ source/joker_effects.c | 77 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) diff --git a/include/game.h b/include/game.h index 6fdaec1..02c3b01 100644 --- a/include/game.h +++ b/include/game.h @@ -82,4 +82,6 @@ int get_played_top(void); JokerObject** get_jokers(void); int get_jokers_top(void); +int get_num_discards_remaining(void); + #endif // GAME_H \ No newline at end of file diff --git a/source/game.c b/source/game.c index 9e5c7b6..5e4ffe1 100644 --- a/source/game.c +++ b/source/game.c @@ -239,6 +239,35 @@ static const Rect SHOP_REROLL_RECT = {88, 96, UNDEFINED, UNDEFI #define PITCH_STEP_UNDISCARD_SFX 2*PITCH_STEP_DRAW_SFX // Naming the stage where cards return from the discard pile to the deck "undiscard" +// get-functions, for other files to view game state (mainly for jokers) +CardObject **get_hand_array(void) { + return hand; +} + +int get_hand_top(void) { + return hand_top; +} + +CardObject **get_played_array(void) { + return played; +} + +int get_played_top(void) { + return played_top; +} + +JokerObject **get_jokers(void) { + return jokers; +} + +int get_jokers_top(void) { + return jokers_top; +} + +int get_num_discards_remaining(void) { + return discards; +} + // General functions void set_seed(int seed) { diff --git a/source/joker_effects.c b/source/joker_effects.c index 5e934ee..7a2eaf3 100644 --- a/source/joker_effects.c +++ b/source/joker_effects.c @@ -215,6 +215,78 @@ static JokerEffect misprint_joker_effect(Joker *joker, Card *scored_card) { return effect; } +static JokerEffect walkie_talkie_joker_effect(Joker *joker, Card *scored_card) { + JokerEffect effect = {0}; + if (scored_card == NULL) + return effect; + + if (scored_card->rank == TEN || scored_card->rank == FOUR) { + effect.chips = 10; + effect.mult = 4; + } + + return effect; +} + +static JokerEffect fibonnaci_joker_effect(Joker *joker, Card *scored_card) { + JokerEffect effect = {0}; + if (scored_card == NULL) + return effect; + + switch (scored_card->rank) { + case ACE: case TWO: case THREE: case FIVE: case EIGHT: + effect.mult = 8; + default: + break; + } + + return effect; +} + +static JokerEffect banner_joker_effect(Joker *joker, Card *scored_card) { + JokerEffect effect = {0}; + if (scored_card != NULL) + return effect; // if card != null, we are not at the end-phase of scoring yet + + effect.chips = 30 * get_num_discards_remaining(); + + return effect; +} + +static JokerEffect mystic_summit_joker_effect(Joker *joker, Card *scored_card) { + JokerEffect effect = {0}; + if (scored_card != NULL) + return effect; // if card != null, we are not at the end-phase of scoring yet + + if (get_num_discards_remaining() == 0) + effect.mult = 15; + + return effect; +} + +static JokerEffect blackboard_joker_effect(Joker *joker, Card *scored_card) { + JokerEffect effect = {0}; + if (scored_card != NULL) + return effect; // if card != null, we are not at the end-phase of scoring yet + + bool all_cards_are_spades_or_clubs = true; + CardObject** hand = get_hand_array(); + int hand_top = get_hand_top(); + for (int i = 0; i < hand_top; i++ ) + { + u8 suit = hand[i]->card->suit; + if (suit == HEARTS || suit == DIAMONDS) { + all_cards_are_spades_or_clubs = false; + break; + } + } + + if (all_cards_are_spades_or_clubs) + effect.xmult = 3; + + return effect; +} + const JokerInfo joker_registry[] = { { COMMON_JOKER, 2, default_joker_effect }, // DEFAULT_JOKER_ID = 0 { COMMON_JOKER, 5, greedy_joker_effect }, // GREEDY_JOKER_ID = 1 @@ -234,6 +306,11 @@ const JokerInfo joker_registry[] = { { COMMON_JOKER, 5, half_joker_effect }, { UNCOMMON_JOKER, 8, joker_stencil_effect }, { COMMON_JOKER, 4, misprint_joker_effect }, + { COMMON_JOKER, 4, walkie_talkie_joker_effect }, + { UNCOMMON_JOKER, 8, fibonnaci_joker_effect }, + { COMMON_JOKER, 5, banner_joker_effect }, + { COMMON_JOKER, 5, mystic_summit_joker_effect }, + { UNCOMMON_JOKER, 6, blackboard_joker_effect }, }; static const size_t joker_registry_size = NUM_ELEM_IN_ARR(joker_registry); From b0a4fc968c11f2914ea5a2b0e190a37f51206b21 Mon Sep 17 00:00:00 2001 From: MeirGavish Date: Thu, 7 Aug 2025 22:48:06 +0300 Subject: [PATCH 2/8] Removed duplicate declarations to fix build --- source/game.c | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/source/game.c b/source/game.c index 5e4ffe1..e067082 100644 --- a/source/game.c +++ b/source/game.c @@ -239,31 +239,6 @@ static const Rect SHOP_REROLL_RECT = {88, 96, UNDEFINED, UNDEFI #define PITCH_STEP_UNDISCARD_SFX 2*PITCH_STEP_DRAW_SFX // Naming the stage where cards return from the discard pile to the deck "undiscard" -// get-functions, for other files to view game state (mainly for jokers) -CardObject **get_hand_array(void) { - return hand; -} - -int get_hand_top(void) { - return hand_top; -} - -CardObject **get_played_array(void) { - return played; -} - -int get_played_top(void) { - return played_top; -} - -JokerObject **get_jokers(void) { - return jokers; -} - -int get_jokers_top(void) { - return jokers_top; -} - int get_num_discards_remaining(void) { return discards; } From 50ec1bcdabc927c59a8aaff8a50f054be627f29d Mon Sep 17 00:00:00 2001 From: MeirGavish Date: Thu, 7 Aug 2025 23:08:35 +0300 Subject: [PATCH 3/8] Added art by @GreenNinja2525 for jokers Walkie-Talkie, Fibonacci, Banner, Mystic Summit, and Blackboard --- graphics/joker_gfx10.grit | 1 + graphics/joker_gfx10.png | Bin 0 -> 1297 bytes graphics/joker_gfx11.grit | 1 + graphics/joker_gfx11.png | Bin 0 -> 543 bytes graphics/joker_gfx9.grit | 1 + graphics/joker_gfx9.png | Bin 0 -> 951 bytes include/joker_gfx.h | 3 +++ source/joker.c | 6 ++++++ 8 files changed, 12 insertions(+) create mode 100644 graphics/joker_gfx10.grit create mode 100644 graphics/joker_gfx10.png create mode 100644 graphics/joker_gfx11.grit create mode 100644 graphics/joker_gfx11.png create mode 100644 graphics/joker_gfx9.grit create mode 100644 graphics/joker_gfx9.png diff --git a/graphics/joker_gfx10.grit b/graphics/joker_gfx10.grit new file mode 100644 index 0000000..a8ac3f6 --- /dev/null +++ b/graphics/joker_gfx10.grit @@ -0,0 +1 @@ +-gB4 -Mw4 -Mh4 -m! -pn 16 \ No newline at end of file diff --git a/graphics/joker_gfx10.png b/graphics/joker_gfx10.png new file mode 100644 index 0000000000000000000000000000000000000000..a87df841486a2e96c128cd632550431600d5a42e GIT binary patch literal 1297 zcmV+s1@8KZP)q~Mdn;uqgJUg11omttT9|(JAc7DF^ zy?JkD)`0{Me){c&th`^m|K6L9$$Kwz{GI|DeB2v3)WLsf{;r&aZ2Z9!1Bu3IH9E-V zQa$DW{JAe3{}ov$s!6!6%ShKME6T~buFFXB&tiEJ5NV$LdTTTC zBSEOn7E%u&C4MbS?dB*l-WGfA?Cs;DY7O{y(4>1KsI18c zKXG}Oc!H4t0C4x%5Y9i}J1AIQ3_ak|99!$7Lk_V06|gad-9Fa8DI(;v(bPwt5C>xc zcx1dSoc=h>=|L%vKi;a~^-pGivq^fBLuNgGlcOUqw$s5nPaQ8dG5X8f2-X|~YX{k2 zcc}twOhr2{Cg0K0Iwm2AFs=1$E`>riba}p9gl_!<79K!Z;aw`&n2H3slS2alMf@Ug z(zN3kkR>V2WphzNy3}{5F@W&bng=X3L&5+f+fT}i1FdJCBrgns_YVFY9jpYPYyf!p znKnJki(v+M2RLohnE^x#s@$CF_-tUh8M2N6caIH4p7)`mP76Mt^XCAW z5EK){fT$AJb@ziz5WF~&OB?`@rZGld0+nDgBs#C&|M%}O z?^7qMRis}#ylt-tem@|>Z~M~nY%axqI#>(9yS=+w?Q64R0$R&_FeK}%$ct@tuv!8^ zDbKdMpD*3S?ee_7L7(8)IDy=rCr^P+ge*RYu#W*7Q*c+S@Vm$3qX1cs$ck%SX8HBj zCeoR7q&}TVM+7|n#;ZN;jF&)A%42t_5{dMaMtRDk#JnSD2AIkrSzV@F7D4i--GXWFmZ2P`HuLd$ObCQ#BTQ^V(!A#*!TXApU3|LOZ|5hB9UtS00000NkvXX Hu0mjfq048x literal 0 HcmV?d00001 diff --git a/graphics/joker_gfx11.grit b/graphics/joker_gfx11.grit new file mode 100644 index 0000000..a8ac3f6 --- /dev/null +++ b/graphics/joker_gfx11.grit @@ -0,0 +1 @@ +-gB4 -Mw4 -Mh4 -m! -pn 16 \ No newline at end of file diff --git a/graphics/joker_gfx11.png b/graphics/joker_gfx11.png new file mode 100644 index 0000000000000000000000000000000000000000..8dd805ced547cc7b9063fb62113605dbfc180214 GIT binary patch literal 543 zcmV+)0^t3LP)MBQJ*`s)c#D)tLvEl;lC31o6+C}xPshQYL6JXpv z2}N?8!2cf4*k%TW{cX}O+Rj%1?3wVOHB$Uxv-F>_ zOl{~?s0NVr{`lkC$5bZWgQx*H95zerPG{^+=ORt$H6TX}#RI_0^8)Mru{aZY4WO95 z@R#BN_y|Z%7i&DmZiZsy=t}XxcLcCcNhU-Mkc7gt@bBwunXDu@R8UE|AZdUmzHk0Z zN-<$j84Lxvwu5WCXdmlDa{xzQisI-?;jZlf5e2-aDv1S>D?tjN2!?)WioD1E*2M!E zRX`Kq+73=c2KzL1m3-D3*=3Npw!4_;(ukKSe$@>blmx@DmQ$mYkPrD)6=>?p3#Mp> z|DUP?l5ljJy7Eb{sVkosw7!-Zyb^5c$_pm0?R+~>&LRjHxDup53MSH!(oD!IgVF?w z4_AO}lewUTX^<5GTLdUF002ovPDHLkV1h^O{G$K> literal 0 HcmV?d00001 diff --git a/graphics/joker_gfx9.grit b/graphics/joker_gfx9.grit new file mode 100644 index 0000000..a8ac3f6 --- /dev/null +++ b/graphics/joker_gfx9.grit @@ -0,0 +1 @@ +-gB4 -Mw4 -Mh4 -m! -pn 16 \ No newline at end of file diff --git a/graphics/joker_gfx9.png b/graphics/joker_gfx9.png new file mode 100644 index 0000000000000000000000000000000000000000..298f796ddaa08d29d19db08d202f2b1784d5d5c0 GIT binary patch literal 951 zcmV;o14#UdP)_0* zp_Jf70$q~QOImXhwG>Kw^FJ_x;OZgHb~d}Szh)9Geh_B%&Fsv+Z{BO z*~vu_ja(e@(r=jaTLg6SsfjVElW%VCazDau{>fL5ENv$y-v*w)HNIy%|4F;fQxjv* zbsaPF3x;fc<)z~Ugb?VuZY!r_QWD%il_!;&A=5KSPw(;&{dB<~!SsE+7YHGS()Ci2 zJ1`*xgb*Zhd85w$L_n1mRo)4<7C^yMpkJQI<&BcHl%NEx#S2C~$vjul0RW`B;Xvcs zflELlm$zMcH>G&4;0LN!M!i%-B9}+<&Q+*d+0PCkOwXA}%#sZPy?lV? z41hU>{<(GA(tm6Gu|?*a0529GiuafA8}(|a16307|81UiyR{(tf zr|p28Jb_id((VOURV$;?Zlcm|8Ya)Kyk7)L*9N)zJWw}CD_NZSb|`IJUoOx%*aObF zv`YfJ`l)W%6xe>89yJjn;sU;7fJ`NMxc>1O5Q%Z0WhoB?aDl^(mTO%GSRcLmeUIfgxCc zXiChIz!E`s2{+~0qjfuYjsb@oEsRb_T`hnmf}Sbz4p_aS(rzO2Clh2-VwxQ~DX(Xe zMrj961njFdoKGh``}w|VW?e>BNd3O5m}Pc3e?Oe=6+Bx&zfxYI>$=qQL78^~zyJ?L zsqfFsF9_cg1OfH^Krvu*dsp~!wBPK#-U|Z2gY->2Ro@BC-*5I?_pE<~0h`-l;QzWF Z{|!9h<4@gXzIy-w002ovPDHLkV1g=0un+(M literal 0 HcmV?d00001 diff --git a/include/joker_gfx.h b/include/joker_gfx.h index 92c3edc..75cfbbc 100644 --- a/include/joker_gfx.h +++ b/include/joker_gfx.h @@ -10,5 +10,8 @@ #include "joker_gfx6.h" #include "joker_gfx7.h" #include "joker_gfx8.h" +#include "joker_gfx9.h" +#include "joker_gfx10.h" +#include "joker_gfx11.h" #endif \ No newline at end of file diff --git a/source/joker.c b/source/joker.c index c302faf..41d1fd1 100644 --- a/source/joker.c +++ b/source/joker.c @@ -105,6 +105,9 @@ void joker_init() joker_gfxTiles[6] = joker_gfx6Tiles; joker_gfxTiles[7] = joker_gfx7Tiles; joker_gfxTiles[8] = joker_gfx8Tiles; + joker_gfxTiles[9] = joker_gfx9Tiles; + joker_gfxTiles[10] = joker_gfx10Tiles; + joker_gfxTiles[11] = joker_gfx11Tiles; joker_gfxPal[0] = joker_gfx0Pal; joker_gfxPal[1] = joker_gfx1Pal; @@ -115,6 +118,9 @@ void joker_init() joker_gfxPal[6] = joker_gfx6Pal; joker_gfxPal[7] = joker_gfx7Pal; joker_gfxPal[8] = joker_gfx8Pal; + joker_gfxPal[9] = joker_gfx9Pal; + joker_gfxPal[10] = joker_gfx10Pal; + joker_gfxPal[11] = joker_gfx11Pal; for (int i = 0; i < num_spritesheets; i++) { From 4492176df21e36d02c745d46c97518fcd4693219 Mon Sep 17 00:00:00 2001 From: theturtlemafia Date: Sat, 2 Aug 2025 00:27:35 -0400 Subject: [PATCH 4/8] allows multiple joker-effect popup texts --- source/joker.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/source/joker.c b/source/joker.c index 41d1fd1..4ffca63 100644 --- a/source/joker.c +++ b/source/joker.c @@ -241,33 +241,44 @@ bool joker_object_score(JokerObject *joker_object, Card* scored_card, int *chips *money += joker_effect.money; // TODO: Retrigger - tte_set_pos(fx2int(joker_object->sprite_object->x) + 8, JOKER_SCORE_TEXT_Y); // Offset of 16 pixels to center the text on the card - - char score_buffer[12]; - + int cursorPosX = fx2int(joker_object->sprite_object->x) + 8; // Offset of 16 pixels to center the text on the card if (joker_effect.chips > 0) { + char score_buffer[12]; + tte_set_pos(cursorPosX, JOKER_SCORE_TEXT_Y); tte_set_special(0xD000); // Blue snprintf(score_buffer, sizeof(score_buffer), "+%d", joker_effect.chips); + tte_write(score_buffer); + cursorPosX += 30; } - else if (joker_effect.mult > 0) + if (joker_effect.mult > 0) { + char score_buffer[12]; + tte_set_pos(cursorPosX, JOKER_SCORE_TEXT_Y); tte_set_special(0xE000); // Red snprintf(score_buffer, sizeof(score_buffer), "+%d", joker_effect.mult); + tte_write(score_buffer); + cursorPosX += 30; } - else if (joker_effect.xmult > 0) + if (joker_effect.xmult > 0) { + char score_buffer[12]; + tte_set_pos(cursorPosX, JOKER_SCORE_TEXT_Y); tte_set_special(0xE000); // Red snprintf(score_buffer, sizeof(score_buffer), "X%d", joker_effect.xmult); + tte_write(score_buffer); + cursorPosX += 30; } - else if (joker_effect.money > 0) + if (joker_effect.money > 0) { + char score_buffer[12]; + tte_set_pos(cursorPosX, JOKER_SCORE_TEXT_Y); tte_set_special(0xC000); // Yellow snprintf(score_buffer, sizeof(score_buffer), "+%d", joker_effect.money); + tte_write(score_buffer); + cursorPosX += 30; } - tte_write(score_buffer); - joker_object->joker->processed = true; // Mark the joker as processed joker_object_shake(joker_object, SFX_CARD_SELECT); // TODO: Add a sound effect for scoring the joker From 5e6d28c66377901329b12b585bdc4fb9e13c4cf2 Mon Sep 17 00:00:00 2001 From: MeirGavish Date: Fri, 8 Aug 2025 00:01:36 +0300 Subject: [PATCH 5/8] Fixed stack top bugs in joker_effects.c - e.g. Blackboard activated if just the first card in hand was not spades/clubs --- include/game.h | 1 + source/game.c | 10 +++++----- source/joker_effects.c | 15 +++++++++------ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/game.h b/include/game.h index 02c3b01..1d99865 100644 --- a/include/game.h +++ b/include/game.h @@ -77,6 +77,7 @@ typedef struct CardObject CardObject; // forward declaration, actually declared typedef struct JokerObject JokerObject; CardObject** get_hand_array(void); int get_hand_top(void); +int hand_get_size(void); CardObject** get_played_array(void); int get_played_top(void); JokerObject** get_jokers(void); diff --git a/source/game.c b/source/game.c index e067082..fe820c5 100644 --- a/source/game.c +++ b/source/game.c @@ -148,6 +148,11 @@ int get_hand_top(void) { return hand_top; } +int hand_get_size(void) +{ + return hand_top + 1; +} + CardObject **get_played_array(void) { return played; } @@ -853,11 +858,6 @@ void hand_change_sort() sort_cards(); } -int hand_get_size() -{ - return hand_top + 1; -} - int hand_get_max_size() { return hand_size; diff --git a/source/joker_effects.c b/source/joker_effects.c index 7a2eaf3..fa6c897 100644 --- a/source/joker_effects.c +++ b/source/joker_effects.c @@ -1,3 +1,4 @@ +#include "game.h" #include "joker.h" #include "util.h" #include "hand_analysis.h" @@ -178,7 +179,8 @@ static JokerEffect half_joker_effect(Joker *joker, Card *scored_card) { if (scored_card != NULL) return effect; // if card != null, we are not at the end-phase of scoring yet - if (get_played_top() + 1 <= 3) // game.c has hand_get_size() but it's not accesible here + int played_size = get_played_top() + 1; + if (played_size <= 3) effect.mult = 20; return effect; @@ -190,12 +192,13 @@ static JokerEffect joker_stencil_effect(Joker *joker, Card *scored_card) { return effect; // if card != null, we are not at the end-phase of scoring yet // +1 xmult per empty joker slot... - int jokers_top = get_jokers_top(); - effect.xmult = (MAX_JOKERS_HELD_SIZE-1) - jokers_top; + int num_jokers = get_jokers_top() + 1; + + effect.xmult = (MAX_JOKERS_HELD_SIZE) - num_jokers; // ...and also each stencil_joker adds +1 xmult JokerObject** jokers = get_jokers(); - for (int i = 0; i < jokers_top; i++ ) + for (int i = 0; i < num_jokers; i++ ) { if (jokers[i]->joker->id == JOKER_STENCIL_ID) effect.xmult++; @@ -271,8 +274,8 @@ static JokerEffect blackboard_joker_effect(Joker *joker, Card *scored_card) { bool all_cards_are_spades_or_clubs = true; CardObject** hand = get_hand_array(); - int hand_top = get_hand_top(); - for (int i = 0; i < hand_top; i++ ) + int hand_size = hand_get_size(); + for (int i = 0; i < hand_size; i++ ) { u8 suit = hand[i]->card->suit; if (suit == HEARTS || suit == DIAMONDS) { From 863e3a34ae0fb9ea2cd429dbe7e05e816a7f4933 Mon Sep 17 00:00:00 2001 From: MeirGavish Date: Fri, 8 Aug 2025 00:31:10 +0300 Subject: [PATCH 6/8] Rearranged jokers for palette optimization (Banner and Mystic Summit don't go well together) --- graphics/joker_gfx10.png | Bin 1297 -> 1023 bytes graphics/joker_gfx11.png | Bin 543 -> 845 bytes source/joker_effects.c | 5 +++-- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/graphics/joker_gfx10.png b/graphics/joker_gfx10.png index a87df841486a2e96c128cd632550431600d5a42e..aca51bc66d535bd70ac6c3ebc6ede6a4d5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t5C>xccx1dSoc=h>=|L%vKi;a~^-pGivq^fB zLuNgGlcOUqw$s5nPaQ8dG5X8f2-X|~YX{k2cc}twOhr2{Cg0K0Iwm2AFs=1$E`>ri zba}p9gl_!<79K!Z;aw`&n2H3slS2alMf@Ug(tot$7?33?&1G{@Lb}v*O~_` zHABJxBim2Pivz7^o+K{}f%gvn9UZI$plkqm_?b36%Zp(Kcn3Ib)0qK83##0l>iBG6 zx*4*L0e6oLMV|McJ_QiQhM<(U?M@3mpY!JcnGh5c#DJ(14M>;;u5XQ_b}!r{1;y{f zw0~Dj(vul<2OT~$$cU>>hXiW@YLyjSDTl{YJ_`UivKSzq0r*t-@Yy!dkROXpkjMjk zzteU1gG>;-IFd^o0Fb6JMqUDyU@{~+uipRn?=bIEC#zMYUpu^QuLyoWAi{6^((-IB z#eO#N9%ZGUyJS^_~S&$hdtFWtoL^1Qx5pWxRxf!v-a zPk~N^EIx>^j{zG~a96AFyT{|B09lU6ifdhF`SsQ&(wTImKAlNN1U&x6t3BtRDk#JnS zD2AIkrSzV@F7D4i--GXWFmZ2P`FD=^rN{;<%f_{_fsp_cIS-F+jf5AYjb`^q3`Sh$ z;#79-;^o95$Skk(1fG1*eiHes!l8T|y;5F?-4xk=9R23kE!}H9h_n3F4?dKRFP)6- o=jp{SZ({Dk)!6s`kDtf?155pP6(W&p{Qv*}07*qoM6N<$f|Pw}aR2}S diff --git a/graphics/joker_gfx11.png b/graphics/joker_gfx11.png index 8dd805ced547cc7b9063fb62113605dbfc180214..1281a78f7e28e13c8e4e82d22e2f201e270deb0d 100644 GIT binary patch delta 823 zcmV-71IYZJ1kDDJBYy)FNklffRrvuRdP%tB zWXy;uP)f19wrSXoKD-||5FrErKq+;!XT+3|geXB=Ul3vhElU;m0SGaIG(X$zQN>XK z9M=E@0Yq?DGFL&Y6R=cTcbs`a5FprsKiOsb#hH=@Hnt4=;+zsTtS1L)5-0LyIK>21FP7Cr^wVz_u( zq_R{&@v_Ti-hneEZF$zZJv^z)!+SRZ25y38_Qw(^UUvJ2y&a~2jV)uXrxOD3^CQq) z!FdeUKj0$)W~Rhb%sgi`offkA^-#it7bRdJP~S#^?|(XVKd&JD{SjzQ0Il__!FgE% znk&}9^P!xm1I2R!WT}Gvu|(fs3w9zg4pOayN^`4`u+BFq4jurNutHx;5RpLzn zSL=Qdyj8}VBZLs6rx@iVcuK(Mr!QUKC6kkAgiM8u!J^E>u;+;=!To zXY4mcQNvRL7Ux8q?55Djt)g+P7|l^0xRb=WZFy}o@=37JYIpQjyQBNz+3Pp|{R|)X zwlL$fbL}WRKRYe7+8y1`MW(81o-RJ4b~6kB{{T~oO{xP!NKgO(002ovPDHLkV1n?P BfCvBp delta 518 zcmV+h0{Q*T2A>3wBYy$rNklMBQJ*`s)c z#D)tLvEl;lC31o6+C}xPshQYL6JXpv2}N?8!2cf4*k%TW{cX}O+Rj%1?3wVOHB$Uxv-F>_Ol{~?s0NVr{`lkC$A45N-GitBIUF`i>`rIw zPUj*`=rtfm48;S$%ku*3{joR`dJUkMzVMgg0r&_=O&4oC#%_jUdFhIXomlvssfU5bep>JNw29ZpBJ>gmKnSfZ0gDj zCa&##J5bId2pG5$q(BNL(vZ?j$SQ-<1d0z=fNYbwpnrsEkQD)3>vPL1x4s-@c~3rL zoxu?x#iiOxhye9iJavNGw?j+`-p*HL9E+#WgvO4}EHnC4IEJ>Hw8m8pAeM8%O$@M1 z@<2pG%k Date: Fri, 8 Aug 2025 01:59:21 +0300 Subject: [PATCH 7/8] Removed magic numbers for card score length and intmax buffer sizes --- include/game.h | 2 ++ include/graphic_utils.h | 3 +++ include/util.h | 2 ++ source/game.c | 2 +- source/joker.c | 19 +++++++++++-------- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/include/game.h b/include/game.h index 1d99865..55e8730 100644 --- a/include/game.h +++ b/include/game.h @@ -6,6 +6,8 @@ #define MAX_JOKERS_HELD_SIZE 5 // This doesn't account for negatives right now. #define MAX_SHOP_JOKERS 2 // TODO: Make this dynamic and allow for other items besides jokers #define MAX_SELECTION_SIZE 5 +#define MAX_CARD_SCORE_DIGITS 2 // Current digit limit for score received from cards including mult etc. from jokers +#define MAX_CARD_SCORE_STR_LEN (MAX_CARD_SCORE_DIGITS + 1) // For the '+' or 'X' #define FRAMES(x) (((x) + game_speed - 1) / game_speed) // TODO: Turn into enum? diff --git a/include/graphic_utils.h b/include/graphic_utils.h index 6c169c7..2791791 100644 --- a/include/graphic_utils.h +++ b/include/graphic_utils.h @@ -43,6 +43,9 @@ // Tile size in pixels, both height and width as tiles are square #define TILE_SIZE 8 +// By default TTE characters occupy a single tile +#define TTE_CHAR_SIZE TILE_SIZE + typedef struct { int left; diff --git a/include/util.h b/include/util.h index 5b3160e..7d9b915 100644 --- a/include/util.h +++ b/include/util.h @@ -37,6 +37,8 @@ static inline int get_digits_even(int n) #define NUM_ELEM_IN_ARR(arr) (sizeof(arr) / sizeof((arr)[0])) +#define INT_MAX_DIGITS 10 // strlen(str(INT_MAX)) = strlen("2147483647") + int int_arr_max(int int_arr[], int size); #endif // UTIL_H \ No newline at end of file diff --git a/source/game.c b/source/game.c index f89a1b6..8acd864 100644 --- a/source/game.c +++ b/source/game.c @@ -1619,7 +1619,7 @@ static void played_cards_update_loop(bool* discarded_card, int* played_selection tte_set_special(0xD000); // Set text color to blue from background memory // Write the score to a character buffer variable - char score_buffer[5]; // Assuming the maximum score is 99, we need 4 characters (2 digits + null terminator) + char score_buffer[INT_MAX_DIGITS + 2]; // for '+' and null terminator snprintf(score_buffer, sizeof(score_buffer), "+%d", card_get_value(played[j]->card)); tte_write(score_buffer); diff --git a/source/joker.c b/source/joker.c index e0a382d..6b30061 100644 --- a/source/joker.c +++ b/source/joker.c @@ -270,42 +270,45 @@ bool joker_object_score(JokerObject *joker_object, Card* scored_card, int *chips *money += joker_effect.money; // TODO: Retrigger + const int joker_score_display_offset_px = (MAX_CARD_SCORE_STR_LEN + 1)*TTE_CHAR_SIZE; + // + 1 For space + int cursorPosX = fx2int(joker_object->sprite_object->x) + 8; // Offset of 16 pixels to center the text on the card if (joker_effect.chips > 0) { - char score_buffer[12]; + char score_buffer[INT_MAX_DIGITS + 2]; // For '+' and null terminator tte_set_pos(cursorPosX, JOKER_SCORE_TEXT_Y); tte_set_special(0xD000); // Blue snprintf(score_buffer, sizeof(score_buffer), "+%d", joker_effect.chips); tte_write(score_buffer); - cursorPosX += 30; + cursorPosX += joker_score_display_offset_px; } if (joker_effect.mult > 0) { - char score_buffer[12]; + char score_buffer[INT_MAX_DIGITS + 2]; tte_set_pos(cursorPosX, JOKER_SCORE_TEXT_Y); tte_set_special(0xE000); // Red snprintf(score_buffer, sizeof(score_buffer), "+%d", joker_effect.mult); tte_write(score_buffer); - cursorPosX += 30; + cursorPosX += joker_score_display_offset_px; } if (joker_effect.xmult > 0) { - char score_buffer[12]; + char score_buffer[INT_MAX_DIGITS + 2]; tte_set_pos(cursorPosX, JOKER_SCORE_TEXT_Y); tte_set_special(0xE000); // Red snprintf(score_buffer, sizeof(score_buffer), "X%d", joker_effect.xmult); tte_write(score_buffer); - cursorPosX += 30; + cursorPosX += joker_score_display_offset_px; } if (joker_effect.money > 0) { - char score_buffer[12]; + char score_buffer[INT_MAX_DIGITS + 2]; tte_set_pos(cursorPosX, JOKER_SCORE_TEXT_Y); tte_set_special(0xC000); // Yellow snprintf(score_buffer, sizeof(score_buffer), "+%d", joker_effect.money); tte_write(score_buffer); - cursorPosX += 30; + cursorPosX += joker_score_display_offset_px; } joker_object->joker->processed = true; // Mark the joker as processed From 039c5771e1707e1111d777ca903671d74bae585d Mon Sep 17 00:00:00 2001 From: MeirGavish Date: Fri, 8 Aug 2025 02:22:02 +0300 Subject: [PATCH 8/8] Grouped Banner with Stencil to optimize palettes (Swapped with Misprint) --- graphics/joker_gfx11.png | Bin 845 -> 855 bytes graphics/joker_gfx8.png | Bin 1105 -> 1085 bytes source/joker_effects.c | 5 ++--- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/graphics/joker_gfx11.png b/graphics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^+Wu>a0E~)E9(Sb z5zt&)Vbh@Q1TtPX7(iwO%sm8sL_nzv(cTX5xrW-w13KMa{60_z-TT|)WBl>!^mP~g zw#Ub4kB?&-H4eEWfKrI=kSy9Fuf+O`5q}`b1nu#0ik9_4!~$1#y2|6pWMa{{IhE@G zrP#W{1l0nh7tyHYD(9_&gAqiAf@%%yr=`(uMeCK;7hH@(#zDlR0Na-8Bf1O z96-j?uMfRSRf0Y+@BMui=o`SI&XR>YAPhq(5c+%_6j?JzT&vP<~H~Q zn+DCIqYTWjFS3H>_ddD@_|VIQ^W%nBDKq>RKac+l6NdP!yMOx?00000NkvXXu0mjf DZ`u@m diff --git a/source/joker_effects.c b/source/joker_effects.c index 2b12211..bab4512 100644 --- a/source/joker_effects.c +++ b/source/joker_effects.c @@ -308,13 +308,12 @@ const JokerInfo joker_registry[] = { { COMMON_JOKER, 4, crafty_joker_effect }, { COMMON_JOKER, 5, half_joker_effect }, { UNCOMMON_JOKER, 8, joker_stencil_effect }, - { COMMON_JOKER, 4, misprint_joker_effect }, + { COMMON_JOKER, 5, banner_joker_effect }, { COMMON_JOKER, 4, walkie_talkie_joker_effect }, { UNCOMMON_JOKER, 8, fibonnaci_joker_effect }, { UNCOMMON_JOKER, 6, blackboard_joker_effect }, { COMMON_JOKER, 5, mystic_summit_joker_effect }, - { COMMON_JOKER, 5, banner_joker_effect }, - + { COMMON_JOKER, 4, misprint_joker_effect }, }; static const size_t joker_registry_size = NUM_ELEM_IN_ARR(joker_registry);