diff --git a/graphics/nums.grit b/graphics/affine_background_gfx.grit similarity index 100% rename from graphics/nums.grit rename to graphics/affine_background_gfx.grit diff --git a/graphics/affine_background_gfx.png b/graphics/affine_background_gfx.png new file mode 100644 index 0000000..7a567dc Binary files /dev/null and b/graphics/affine_background_gfx.png differ diff --git a/graphics/blinds_gfx.grit b/graphics/blinds_gfx.grit index 0196d39..176fddf 100644 --- a/graphics/blinds_gfx.grit +++ b/graphics/blinds_gfx.grit @@ -1 +1 @@ --gB8 -mR8 -mRtf -p! \ No newline at end of file +-gB4 -Mw4 -Mh4 -p! \ No newline at end of file diff --git a/graphics/blinds_gfx.png b/graphics/blinds_gfx.png index cc681a4..eadfe11 100644 Binary files a/graphics/blinds_gfx.png and b/graphics/blinds_gfx.png differ diff --git a/graphics/deck_gfx.grit b/graphics/deck_gfx.grit index 94f0b72..f677be5 100644 --- a/graphics/deck_gfx.grit +++ b/graphics/deck_gfx.grit @@ -1 +1 @@ --gB4 -Mw4 -Mh4 \ No newline at end of file +-gB4 -Mw4 -Mh4 -m! \ No newline at end of file diff --git a/graphics/nums.png b/graphics/nums.png deleted file mode 100644 index 26fd35c..0000000 Binary files a/graphics/nums.png and /dev/null differ diff --git a/include/blind.h b/include/blind.h new file mode 100644 index 0000000..299cfec --- /dev/null +++ b/include/blind.h @@ -0,0 +1,17 @@ +#ifndef BLIND_H +#define BLIND_H + +#include "sprite.h" + +enum BlindType +{ + SMALL_BLIND, + BIG_BLIND, + BOSS_BLIND +}; + +void blinds_init(); + +Sprite *blind_token_new(enum BlindType type, int x, int y, int sprite_index); + +#endif // BLIND_H \ No newline at end of file diff --git a/source/blind.c b/source/blind.c new file mode 100644 index 0000000..aceb9c5 --- /dev/null +++ b/source/blind.c @@ -0,0 +1,39 @@ +#include + +#include "blind.h" + +#include "blinds_gfx.h" + +void blinds_init() +{ + // Blind graphics + // Small Blind (fighting grit every step of the way as usual) + //memcpy(&tile_mem[4][832], blinds_gfxTiles, blinds_gfxTilesLen); + GRIT_CPY(&tile_mem[4][832], blinds_gfxTiles); + const u16 small_blind_token_palette[4] = {0x7FFF, 0x34A1, 0x5DCB, 0x5104}; + memcpy16(&pal_obj_mem[17], &small_blind_token_palette, sizeof(small_blind_token_palette) / 2); +} + +Sprite *blind_token_new(enum BlindType type, int x, int y, int sprite_index) +{ + Sprite *sprite = NULL; + + switch (type) + { + case SMALL_BLIND: + sprite = sprite_new(ATTR0_SQUARE | ATTR0_4BPP, ATTR1_SIZE_32x32, 832, 1, sprite_index); + break; + case BIG_BLIND: + // Use the big blind sprite + break; + case BOSS_BLIND: + // Use the boss blind sprite + break; + default: + return NULL; + } + + sprite_position(sprite, x, y); + + return sprite; +} diff --git a/source/game.c b/source/game.c index 6520523..3d7ef36 100644 --- a/source/game.c +++ b/source/game.c @@ -7,6 +7,7 @@ #include "sprite.h" #include "card.h" +#include "blind.h" #include "background_gfx.h" #include "background_play_gfx.h" @@ -18,12 +19,15 @@ static int timer = 1; // This might already exist in libtonc but idk so i'm just static int game_speed = 1; static int background = 0; -static enum GameState game_state = GAME_PLAYING; +static enum GameState game_state = GAME_ROUND_END; static enum HandState hand_state = HAND_DRAW; static enum PlayState play_state = PLAY_PLAYING; static enum HandType hand_type = NONE; +static Sprite *playing_blind_token = NULL; // The sprite that displays the blind when in "GAME_PLAYING/GAME_ROUND_END" state +static Sprite *round_end_blind_token = NULL; // The sprite that displays the blind when in "GAME_ROUND_END" state + static int hands = 4; static int discards = 4; @@ -549,6 +553,10 @@ void deck_shuffle() // Game functions void game_init() { + playing_blind_token = blind_token_new(SMALL_BLIND, 8, 18, 33); // Create the blind token sprite at the top left corner + round_end_blind_token = blind_token_new(SMALL_BLIND, 82, 78, 34); // Create the blind token sprite for round end + obj_hide(round_end_blind_token->obj); // Hide the blind token sprite for now + // Fill the deck with all the cards. Later on this can be replaced with a more dynamic system that allows for different decks and card types. for (int suit = 0; suit < NUM_SUITS; suit++) { @@ -1304,6 +1312,19 @@ void game_round_end() const unsigned short tile_map5[17] = {se_mem[31][8 + 32 * y], 0x0001, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0401}; memcpy(&se_mem[31][8 + 32 * y], tile_map5, sizeof(tile_map5)); } + else if (timer_offset == 30) + { + obj_unhide(round_end_blind_token->obj, 0); + tte_printf("#{P:112,88; cx:0xE000}%d", blind_requirement); + + int y = 12; + + unsigned short tile_map3[17] = {se_mem[31][8 + 32 * (y - 1)], 0x0001, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0015, 0x0401}; + memcpy(&se_mem[31][8 + 32 * (y - 1)], tile_map3, sizeof(tile_map3)); + + const unsigned short tile_map4[17] = {se_mem[31][8 + 32 * y], 0x0001, 0x0054, 0x0055, 0x0055, 0x0055, 0x0055, 0x0055, 0x0055, 0x0055, 0x0055, 0x0055, 0x0055, 0x0055, 0x0055, 0x0454, 0x0401}; + memcpy(&se_mem[31][8 + 32 * y], tile_map4, sizeof(tile_map4)); + } } } diff --git a/source/main.c b/source/main.c index c11fc09..8020afc 100644 --- a/source/main.c +++ b/source/main.c @@ -5,12 +5,13 @@ #include "sprite.h" #include "card.h" #include "game.h" +#include "blind.h" // Graphics #include "deck_gfx.h" #include "background_gfx.h" #include "background_play_gfx.h" -#include "nums.h" +#include "affine_background_gfx.h" // Audio #include "soundbank.h" @@ -25,16 +26,16 @@ void init_map() // Temp function ripped from libtonc example { // Grit is fucking garbage and doesn't allow you to have a palette offset, they all get loaded at 0x0000. I have no manually change each tile's palette bank - unsigned int correctedTiles[numsTilesLen / 4]; - for (int i = 0; i < numsTilesLen / 4; i++) + unsigned int correctedTiles[affine_background_gfxTilesLen / 4]; + for (int i = 0; i < affine_background_gfxTilesLen / 4; i++) { - correctedTiles[i] = numsTiles[i] | 0xF0F0F0F0; // I brute forced this. I have no idea how this would and does work, but it does. We'll just leave this here for now. + correctedTiles[i] = affine_background_gfxTiles[i] | 0xF0F0F0F0; // I brute forced this. I have no idea how this would and does work, but it does. We'll just leave this here for now. // Actually for future reference, each number seems to equate to an XY on the palette, so 0xF0F0F0F0 would just push everything down 15 colors, since the second number isn't set. } - memcpy(&tile8_mem[2], correctedTiles, numsTilesLen); - GRIT_CPY(&se_mem[2], numsMap); - memcpy16(&pal_bg_mem[16 * 15], numsPal, 5); + memcpy(&tile8_mem[2], correctedTiles, affine_background_gfxTilesLen); + GRIT_CPY(&se_mem[2], affine_background_gfxMap); + memcpy16(&pal_bg_mem[16 * 15], affine_background_gfxPal, 5); bgaff = bg_aff_default; } @@ -62,12 +63,12 @@ void init() // Load the tiles and palette // Background memcpy(pal_bg_mem, background_gfxPal, 64); // This '64" isn't a specific number, I'm just using it to prevent the text colors from being overridden - memcpy(&tile8_mem[1], background_gfxTiles, background_gfxTilesLen); // Deadass i have no clue how any of these memory things work but I just messed with them until stuff worked - memcpy(&se_mem[31], background_gfxMap, background_gfxMapLen); + GRIT_CPY(&tile8_mem[1], background_gfxTiles); // Deadass i have no clue how any of these memory things work but I just messed with them until stuff worked + GRIT_CPY(&se_mem[31], background_gfxMap); // Deck graphics - memcpy(&tile_mem[4], deck_gfxTiles, deck_gfxTilesLen); - memcpy(pal_obj_mem, deck_gfxPal, deck_gfxPalLen); + GRIT_CPY(&tile_mem[4], deck_gfxTiles); + GRIT_CPY(pal_obj_mem, deck_gfxPal); // Set up the video mode REG_BG0CNT = BG_PRIO(0) | BG_CBB(0) | BG_SBB(30) | BG_4BPP; @@ -103,6 +104,7 @@ void init() // Initialize subsystems sprite_init(); + blinds_init(); game_init(); } @@ -110,12 +112,13 @@ void background_update() // This needs to be called before update() and draw() b { static uint timer = 0; timer++; - asx.alpha += 30; - asx.tex_x += 78; + + // These values are not permament, just the current configuration for the affine background + asx.tex_x += 5; asx.tex_y += 12; - asx.sx = (lu_sin(timer * 100) * 4 ) >> 8; // Scale the sine value to fit in a s16 + asx.sx = (lu_sin(timer * 100)) >> 8; // Scale the sine value to fit in a s16 asx.sx += 256; // Add 256 to the sine value to make it positive - asx.sy = (lu_sin(timer * 100 + 0x4000) * 4 ) >> 8; // Scale the sine value to fit in a s16 + asx.sy = (lu_sin(timer * 100 + 0x4000)) >> 8; // Scale the sine value to fit in a s16 asx.sy += 256; // Add 256 to the sine value to make it positive bg_rotscale_ex(&bgaff, &asx); REG_BG_AFFINE[2]= bgaff;