From c58b569516865dc7520b1be00ac42c64b5391eb8 Mon Sep 17 00:00:00 2001 From: cellos51 Date: Mon, 30 Jun 2025 03:18:04 -0400 Subject: [PATCH] Added more stuff to the end round, made the blind token a sprite and toned dow n the background animation a bit. --- .../{nums.grit => affine_background_gfx.grit} | 0 graphics/affine_background_gfx.png | Bin 0 -> 2983 bytes graphics/blinds_gfx.grit | 2 +- graphics/blinds_gfx.png | Bin 865 -> 597 bytes graphics/deck_gfx.grit | 2 +- graphics/nums.png | Bin 2948 -> 0 bytes include/blind.h | 17 ++++++++ source/blind.c | 39 ++++++++++++++++++ source/game.c | 23 ++++++++++- source/main.c | 33 ++++++++------- 10 files changed, 98 insertions(+), 18 deletions(-) rename graphics/{nums.grit => affine_background_gfx.grit} (100%) create mode 100644 graphics/affine_background_gfx.png delete mode 100644 graphics/nums.png create mode 100644 include/blind.h create mode 100644 source/blind.c 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 0000000000000000000000000000000000000000..7a567dc88ab88fa6a85a61877c8a4ab43c2946fd GIT binary patch literal 2983 zcmeH}e@qi+7{?ETP%$77(E&qjaQ*-k9U}$-FBYUAf`Tl9h(ESPL^nYJ3#IEJmLKAv z+1zB4;^7(wk(JINbAt7hO;O`G5urkaA~+8yLQAQ%<$AaGXtt4M0G{z?eS6G4y(l=6lkC~G|gjU0fWOY~N(XqQDt&DROatCF16 zBYw0&3DZ-C-?Zjwm2gTsIH()Ek|`jylmw&9(`neW3ZcnY1bkEIOHIR+0BOTfI!B}1 zttU40C-~p<5(jJ@Aml@0M}tvq^0F3EO%&@Ciq*rMenPIEUG@zj_J)z&g$ew&>%|7C zte7OfG6(vLh<@DedEhZ2b(xYhI^T5QXR_pjzk{B*EBl7~Xsu&k={Xd;082v?++MV^ zeM`kC_66(}n$XPgaB1mrxqxCNu$1$ZU-~#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<%|FPK48 z4>Hptn)EwnJyDh|q;lp0axNg}0y1$fApb`JNz>0Bj(i)eD_a8ogrUf-F=6$b1Nnad DhT-E# literal 0 HcmV?d00001 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 cc681a4b5e50e600244650b2fbb55afb87bb7749..eadfe11d5dbe71d1ab720657e706861b872fc6dc 100644 GIT binary patch delta 499 zcmVOu z07Rh_YIu=+Ab%YOD=!IvCW-(60hvieK~!ko?U?Ox!ypVmf%6s~!5M^k7{v2%o&!c; z4);&-QHrtnP)dW|UC%k!$rF-nlyLTdQtG_>-@fmhA@k{e{v@{6-oAO;Hnc>{;^#GD z%tXxQ=drv*oC>5R2{Zb6FL`ScM)PZ}!S9t)R{KSKLVs(0$>SsRbuWA@sd&Qk7+%cl zLzYza!-~d9mQr5F6xLd%lsZegAlLogm+Lw#|D7Y3{8GOtxxKJD{b_-aMEqAos{3Z8!%||V5!ecdEZU% z!i(cLK!2lOY79(`uAcaF?-v>-k1L^0y%_vxeO zj{+EDxN{CX`ay8cF=Gtqi^z!nR!aOdhK?|Xepl;U*EPA*LmmnKnv&{=T{x1zW#TFI zUl+b!uU`RR-+m#Z`D=d-tu8>1B-Ac`WAP9mW2!bFw^97Wv0y{Th$@~BS002ovPDHLkV1i!p=*9p5 delta 769 zcmV+c1OEKg1mOlDiBL{Q4GJ0x0000DNk~Le0000;0000O2nGNE09j+Zu#q8B38nyo z0K2#*bfb}cAb%VM8Zh`T_3;1z0;NerK~z}7?U=o48$lF>&n$*?agjtJkSZ=>K?+w% z5mFcul03nhpa&4DTnCau0@bO)K7bH$mC_Ot7!+LCl?s8B!mbR$YrC*JSCeYQc(`|d zWiZ4CmfhK%y-1(VoVzOlhqku+lDqcn$47xg&3g^D{(rMiKa=Zsn*+A~m+v2(^@R(} z;kaaPe!WqN2BpAUmt%I$gUUuUCx}1b09;&P@qgmVp(upkW%5eAenIf{N44g`R?Us7E)$TKH96{Xs@<7 z*7v^0zJIFiJYH;SOq~x^2pre^70Nwpn;jOy+Gc05r*t?jv9;Zox{GY?>E!1mh)#Y^ z&c80lnD-h|cM-R=bZ7X&IhmH|HV0C;DYJhEkzZHa}PPk#+xpIov6(!ZcOcI|zao-2se_%<^s zw8Le){oiDpx3zfvIyD9WRd+NRd9`+`&71e=QgzMxrd#waM5=BU8^mUqyTaY4h1O#Gt2;t{f`{-bHg}glx z0Dn*nTjKa^wp1v`XEPMTmfwToeVYf=uPq-veM`1_pCzZ}=%4S_UKz z&axnJa5zY*?jiqCT&>n60EB>2A#a1DLrMaG5Kt=QZE$o*01yI7g}e!e1QY@)1WXL5 z5HK;IY+#&#Oi+|!z;K`_#em^JQL=%#m#6*#*k19E*RM>p00000NkvXXu0mjf*Vkge 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 26fd35cfecf7869889c0e9f7626dd5e406e1fe94..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2948 zcmeH}{ZA8j9LK*9EVT?QiDm<)z;td57Z*FDv};e=VtELHC^C6y#U-l)oJ2qvV9$r@ z7!H~&aYH~3*C+-?yJeBYE?6O(FvB<)QS2C$M-Ql7+Z@ndd%f-sfAOd7ALtMF@OgdT z_sQM+-uc{pm3c@O%8BFv076rerC9(3(5C@_&7u$aXYYQ>RApH*ae(RfT`*k)DHGEZ z0r*K1LKbeI>zGfHv(f>m-U+}3H2`iJU04L5;sXGdPXNGg0^s%1R>R?s=mplvG?^6a z2H8M*YjaT*O*WP$A1?zSten{big*0{l!n3ODd|bUORTMdoN!6y)olQ922-SoN2~s_ zPNwPRQ@3mwIoY)$y_mW;>R|sHO_10=VmS~mh+9~FN7OU7t8y%7OL27k6<*RhphwI-J^D4ms)rts^s3kMozX|3@M+4Uu;K$S7-yre3W>g3Aj zo@4rDG@Cc$X;*$}7s;7!`QiN?eZ!oYvHb+mMeqdb?!?Bh!s1$zyiVST=%0!xI?Aq5 zo>EcoQA3=W#l5LEZlhf5z;o=%gKT9^T+NlzbJxE`;0oXK%LnpoY0lgx*T?Dx=k1#J zhwOOHigFWG!tS*zC5zd$Dk|G+65v}yZ#jo5KU7cgAjnrwy_sM&MfKkuYwL~uns1%M z6n`Mv!EUomftPqi?q&@FzYPx$l_F~`_of}68IOmENV3aSwibz<_nEqG+B~S-x_~MA z5T47))ft{R+`n{vzG}yz$!O;n1no}?Kk%L??ulW2=V1767-QZnj*qX(9E?QkBFPHx zVfqdY)Vm@GF7Q=e`CkpZ8DZW;J&G#E%`5yLEBgonv1;0EOs|gIOH0HsYP{+zJ(4Lj z6U4Y9x+p}42_RoCH5tts#cv|8(5K6|ye_)~<8$rR4{%&>LF??g<^(8Fp5wKG=IxZ+ie zjK=0i{HjqvyM=U6ZU3M@#E@qmqA>KISG{aDAQ)x3-QN?`J4X=uRjl(yrmadvS-kh( zT1U1S^aXdN5yOlch$k5lv>`q@9nnNa>6CILkfi_@% 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;