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 00000000..5623e608 Binary files /dev/null and b/graphics/joker_gfx.png differ diff --git a/include/blind.h b/include/blind.h index e42f88d6..3c113cbe 100644 --- a/include/blind.h +++ b/include/blind.h @@ -38,7 +38,7 @@ enum BlindState BLIND_SKIPPED }; -void blinds_init(); +void blind_init(); int blind_get_requirement(int type, int ante); int blind_get_reward(int type); diff --git a/include/card.h b/include/card.h index ceac7a88..314866c1 100644 --- a/include/card.h +++ b/include/card.h @@ -52,6 +52,9 @@ typedef struct bool selected; } CardObject; +// Card functions +void card_init(); + // Card methods Card *card_new(u8 suit, u8 rank); void card_destroy(Card **card); diff --git a/include/joker.h b/include/joker.h new file mode 100644 index 00000000..4488380f --- /dev/null +++ b/include/joker.h @@ -0,0 +1,79 @@ +#ifndef JOKER_H +#define JOKER_H + +#define JOKER_TID 880 // Tile ID for the starting index in the tile memory +#define JOKER_PB 4 // Palette bank for the default jokers + +#include "sprite.h" +#include "card.h" + +#define BASE_EDITION 0 +#define FOIL_EDITION 1 +#define HOLO_EDITION 2 +#define POLY_EDITION 3 +#define NEGATIVE_EDITION 4 + +#define COMMON_JOKER 0 +#define UNCOMMON_JOKER 1 +#define RARE_JOKER 2 +#define LEGENDARY_JOKER 3 + +#define MAX_JOKERS 2 // The current maximum jokers added + +#define DEFAULT_JOKER_ID 0 +#define GREEDY_JOKER_ID 1 // This is just an example to show the patern of making joker IDs + +typedef struct +{ + u8 id; // Unique ID for the joker, used to identify different jokers + u8 modifier; // base, foil, holo, poly, negative + u8 value; + u8 rarity; +} Joker; + +typedef struct // copy of CardObject in card.h +{ + Joker *joker; + Sprite *sprite; + FIXED tx, ty; + FIXED x, y; + FIXED vx, vy; + FIXED tscale; + FIXED scale; + FIXED vscale; + FIXED trotation; + FIXED rotation; + FIXED vrotation; +} JokerObject; + +typedef struct // These jokers are triggered after the played hand has finished scoring. +{ + int chips; + int mult; + int xmult; + int money; + bool retrigger; // Retrigger played hand (e.g. "Dusk" joker, even though on the wiki it says "On Scored" it makes more sense to have it here) +} IndependentEffect; + +typedef struct +{ + int chips; + int mult; + int xmult; + int money; + bool retrigger; // Retrigger scored card +} OnScoredEffect; + +void joker_init(); + +Joker *joker_new(u8 id); +void joker_destroy(Joker **joker); + +// Unique effects like "Four Fingers" or "Credit Card" will be hard coded into game.c with a conditional check for the joker ID from the players owned jokers +// game.c should probably be restructured so most of the variables in it are moved to some sort of global variable header file so they can be easily accessed and modified for the jokers +IndependentEffect joker_independent_effect(Joker *joker); +OnScoredEffect joker_on_scored(Joker *joker, Card *scored_card); + +void joker_object_score(JokerObject *joker_object); // This doesn't actually score anything, it just performs an animation and plays a sound effect + +#endif // JOKER_H \ No newline at end of file diff --git a/source/blind.c b/source/blind.c index aaf560ec..0b512e48 100644 --- a/source/blind.c +++ b/source/blind.c @@ -4,24 +4,20 @@ #include "blinds_gfx.h" #include "graphic_utils.h" +// Palettes for the blinds (Transparency, Text Color, Shadow, Highlight, Main Color) Use this: http://www.budmelvin.com/dev/15bitconverter.html static const u16 small_blind_token_palette[PAL_ROW_LEN] = {0x0000, 0x7FFF, 0x34A1, 0x5DCB, 0x5104, 0x55A0, 0x2D01, 0x34E0}; static const u16 big_blind_token_palette[PAL_ROW_LEN] = {0x0000, 0x2527, 0x15F5, 0x36FC, 0x1E9C, 0x01B4, 0x0D0A, 0x010E}; static const u16 boss_blind_token_palette[PAL_ROW_LEN] = {0x0000, 0x2CC9, 0x3D0D, 0x5E14, 0x5171}; // This variable is temporary, each boss blind will have its own unique palette -void blinds_init() +void blind_init() { // Blind graphics (fighting grit every step of the way as usual) GRIT_CPY(&tile_mem[4][SMALL_BLIND_TID], blinds_gfxTiles); - // Palettes for the blinds (Transparency, Text Color, Shadow, Highlight, Main Color) Use this: http://www.budmelvin.com/dev/15bitconverter.html - // Small Blind - - memcpy16(&pal_obj_mem[16 * SMALL_BLIND_PB], &small_blind_token_palette, sizeof(small_blind_token_palette) / 2); - // Big Blind - memcpy16(&pal_obj_mem[16 * BIG_BLIND_PB], &big_blind_token_palette, sizeof(big_blind_token_palette) / 2); - + memcpy16(&pal_obj_mem[PAL_ROW_LEN * SMALL_BLIND_PB], &small_blind_token_palette, sizeof(small_blind_token_palette) / 2); + memcpy16(&pal_obj_mem[PAL_ROW_LEN * BIG_BLIND_PB], &big_blind_token_palette, sizeof(big_blind_token_palette) / 2); // Boss Blind (This is temporary. Each boss blind is unique and will have to have its own graphics and palette which will probably be stored in some huge array) - memcpy16(&pal_obj_mem[16 * BOSS_BLIND_PB], &boss_blind_token_palette, sizeof(boss_blind_token_palette) / 2); + memcpy16(&pal_obj_mem[PAL_ROW_LEN * BOSS_BLIND_PB], &boss_blind_token_palette, sizeof(boss_blind_token_palette) / 2); } int blind_get_requirement(int type, int ante) diff --git a/source/card.c b/source/card.c index 62655464..4848c20d 100644 --- a/source/card.c +++ b/source/card.c @@ -3,6 +3,8 @@ #include #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(); }