From 4a5644eddbcb0bf8a2d11d2d4aa1ae000900448d Mon Sep 17 00:00:00 2001 From: cellos51 Date: Thu, 17 Jul 2025 21:47:50 -0400 Subject: [PATCH] Defining a basic system for jokers --- graphics/joker_gfx.grit | 1 + graphics/joker_gfx.png | Bin 0 -> 862 bytes include/blind.h | 2 +- include/card.h | 3 ++ include/joker.h | 79 ++++++++++++++++++++++++++++++++++++++++ source/blind.c | 14 +++---- source/card.c | 8 ++++ source/game.c | 9 +---- source/joker.c | 36 ++++++++++++++++++ source/main.c | 10 ++--- 10 files changed, 139 insertions(+), 23 deletions(-) create mode 100644 graphics/joker_gfx.grit create mode 100644 graphics/joker_gfx.png create mode 100644 include/joker.h create mode 100644 source/joker.c diff --git a/graphics/joker_gfx.grit b/graphics/joker_gfx.grit new file mode 100644 index 00000000..f677be59 --- /dev/null +++ b/graphics/joker_gfx.grit @@ -0,0 +1 @@ +-gB4 -Mw4 -Mh4 -m! \ No newline at end of file diff --git a/graphics/joker_gfx.png b/graphics/joker_gfx.png new file mode 100644 index 0000000000000000000000000000000000000000..5623e6089c218348eb80fed3f95d7f6f36197e9f GIT binary patch literal 862 zcmV-k1EKthP)z@;j|==^1poj5AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUy24YJ`L;wH)0002_L%V+f000SaNLh0L01FcU01FcV0GgZ_00007 zbV*G`2k8e976~X@#=vm^00N>(L_t(o!^Ky}4o)ujt^?0|0RJ`O8KLYndwAu7{v@wqi`0F}W^ty5?0wOM%OLU<^n}wxD)qoC~xJ zIJtHJQh}&cfMs~dwUaO+E0H($fO75h1OOJmf`Oi2f}UTlc$&^uazIvr?IIC-2`tCF z(^|-^l@WR+8Pm<}z0j%g=_EF0?WSNCNb)ZrSi70v>y*~y3acQ^dU`An9s^MnX*xdm zq*XX~V*`W`AY|3R{(Sw0{muetf63!oDBya45C9?N+U9x)IOnM$VeO{k$+48J&&dlx zVHFUFM1P2)NF^Tcv|9|)uHL9|Z(S>K-fR~U2m+w+L;WjAuUa@QNqWi(l o43Np_bbGl*y!z#oy!Q3{KfH-~4wy$>$p8QV07*qoM6N<$f;4P$8vp #include +#include "deck_gfx.h" + // Audio #include "soundbank.h" @@ -14,6 +16,12 @@ const static u16 card_sprite_lut[NUM_SUITS][NUM_RANKS] = { {624, 640, 656, 672, 688, 704, 720, 736, 752, 768, 784, 800, 816} }; +void card_init() +{ + GRIT_CPY(&tile_mem[4], deck_gfxTiles); + GRIT_CPY(pal_obj_mem, deck_gfxPal); +} + // Card methods Card *card_new(u8 suit, u8 rank) { diff --git a/source/game.c b/source/game.c index e7811a6d..ccfb2f22 100644 --- a/source/game.c +++ b/source/game.c @@ -776,11 +776,6 @@ void hand_set_focus(int index) mmEffectEx(&sfx_focus); } -int hand_get_focus() -{ - return card_focused; -} - void hand_select() { if (hand_state != HAND_SELECT || hand[card_focused] == NULL) return; @@ -978,11 +973,11 @@ static void game_playing_process_input_and_state() { if (key_hit(KEY_LEFT)) { - hand_set_focus(hand_get_focus() + 1); // The reason why this adds 1 is because the hand is drawn from right to left. There is no particular reason for this, it's just how I did it. + hand_set_focus(card_focused + 1); // The reason why this adds 1 is because the hand is drawn from right to left. There is no particular reason for this, it's just how I did it. } else if (key_hit(KEY_RIGHT)) { - hand_set_focus(hand_get_focus() - 1); + hand_set_focus(card_focused - 1); } if (key_hit(KEY_A)) diff --git a/source/joker.c b/source/joker.c new file mode 100644 index 00000000..3f07e427 --- /dev/null +++ b/source/joker.c @@ -0,0 +1,36 @@ +#include + +#include "joker.h" +#include "joker_gfx.h" +#include "graphic_utils.h" + +const static u8 joker_data_lut[MAX_JOKERS][2] = // Rarity, Value +{ + {COMMON_JOKER, 2}, // Default Joker + {COMMON_JOKER, 5}, // Greedy Joker +}; + +void joker_init() +{ + GRIT_CPY(&tile_mem[4][JOKER_TID], joker_gfxTiles); + memcpy16(&pal_obj_mem[PAL_ROW_LEN * JOKER_PB], joker_gfxPal, sizeof(joker_gfxPal) / 2); +} + +Joker *joker_new(u8 id) +{ + Joker *joker = malloc(sizeof(Joker)); + + joker->id = id; // TODO: Make this random later + joker->modifier = BASE_EDITION; // TODO: Make this random later + joker->value = joker_data_lut[id][1]; + joker->rarity = joker_data_lut[id][0]; + + return joker; +} + +void joker_destroy(Joker **joker) +{ + if (*joker == NULL) return; + free(*joker); + *joker = NULL; +} \ No newline at end of file diff --git a/source/main.c b/source/main.c index ad10ee12..1cb00e25 100644 --- a/source/main.c +++ b/source/main.c @@ -6,10 +6,10 @@ #include "card.h" #include "game.h" #include "blind.h" +#include "joker.h" #include "graphic_utils.h" // Graphics -#include "deck_gfx.h" #include "background_gfx.h" #include "affine_background_gfx.h" @@ -60,10 +60,6 @@ void init() pal_bg_bank[14][15] = 0x213F; // Red pal_bg_bank[15][15] = CLR_WHITE; - // Deck graphics - GRIT_CPY(&tile_mem[4], deck_gfxTiles); - GRIT_CPY(pal_obj_mem, deck_gfxPal); - // Set up the video mode // BG0 is the TTE text layer REG_BG0CNT = BG_PRIO(0) | BG_CBB(TTE_CBB) | BG_SBB(TTE_SBB) | BG_4BPP; @@ -101,7 +97,9 @@ void init() // Initialize subsystems sprite_init(); - blinds_init(); + card_init(); + blind_init(); + joker_init(); game_init(); }