From db27962623e592c950f782e0f386ad5d03de86f7 Mon Sep 17 00:00:00 2001 From: Geralt <84459734+MathisMartin31@users.noreply.github.com> Date: Thu, 16 Apr 2026 10:52:39 +0200 Subject: [PATCH] Implement boss blind graphics (#352) * Created sprite bank for all blinds * progress city, it's a beatiful city that progress city! * Sprite appears in blind selection screen * Added all blind colors * fix magic numbers + disable boss reroll * Fix boss blind token not moving after a reroll * fix always rolling the Needle due to choosing too early for the rng seed to be set * No need for affine sprite for blind tokens, regular is enough * address Copilot's review 1/2 * address Copilot's review 2/2 * correct Blind Tokens/Types * Index palette colors into the files instead of code * Fix blind sprites (flip bug not solved) * Fix magic number, tile index and Mark colors * load boss blind palette only when changing spritesheet * Adressing clang format and ease of modification of the blinds' list * Removed some magic numbers --------- Co-authored-by: MathisMartin31 --- graphics/big_blind_gfx.grit | 1 - graphics/big_blind_gfx.png | Bin 425 -> 0 bytes graphics/blind_gfx0.grit | 1 + graphics/blind_gfx0.png | Bin 0 -> 393 bytes graphics/blind_gfx1.grit | 1 + graphics/blind_gfx1.png | Bin 0 -> 377 bytes graphics/blind_gfx10.grit | 1 + graphics/blind_gfx10.png | Bin 0 -> 364 bytes graphics/blind_gfx11.grit | 1 + graphics/blind_gfx11.png | Bin 0 -> 383 bytes graphics/blind_gfx12.grit | 1 + graphics/blind_gfx12.png | Bin 0 -> 284 bytes graphics/blind_gfx13.grit | 1 + graphics/blind_gfx13.png | Bin 0 -> 345 bytes graphics/blind_gfx14.grit | 1 + graphics/blind_gfx14.png | Bin 0 -> 343 bytes graphics/blind_gfx15.grit | 1 + graphics/blind_gfx15.png | Bin 0 -> 356 bytes graphics/blind_gfx16.grit | 1 + graphics/blind_gfx16.png | Bin 0 -> 343 bytes graphics/blind_gfx17.grit | 1 + graphics/blind_gfx17.png | Bin 0 -> 346 bytes graphics/blind_gfx2.grit | 1 + graphics/blind_gfx2.png | Bin 0 -> 366 bytes graphics/blind_gfx3.grit | 1 + graphics/blind_gfx3.png | Bin 0 -> 380 bytes graphics/blind_gfx4.grit | 1 + graphics/blind_gfx4.png | Bin 0 -> 357 bytes graphics/blind_gfx5.grit | 1 + graphics/blind_gfx5.png | Bin 0 -> 367 bytes graphics/blind_gfx6.grit | 1 + graphics/blind_gfx6.png | Bin 0 -> 387 bytes graphics/blind_gfx7.grit | 1 + graphics/blind_gfx7.png | Bin 0 -> 369 bytes graphics/blind_gfx8.grit | 1 + graphics/blind_gfx8.png | Bin 0 -> 378 bytes graphics/blind_gfx9.grit | 1 + graphics/blind_gfx9.png | Bin 0 -> 363 bytes graphics/boss_blind_gfx.grit | 1 - graphics/boss_blind_gfx.png | Bin 402 -> 0 bytes graphics/small_blind_gfx.grit | 1 - graphics/small_blind_gfx.png | Bin 423 -> 0 bytes include/blind.h | 103 ++++++++----- include/blind_gfx.h | 25 ++++ include/def_blind_gfx_table.h | 18 +++ include/joker.h | 11 +- source/blind.c | 267 +++++++++++++++++++++++++--------- source/game.c | 220 +++++++++++++++++++--------- source/joker.c | 2 +- 49 files changed, 483 insertions(+), 184 deletions(-) delete mode 100644 graphics/big_blind_gfx.grit delete mode 100644 graphics/big_blind_gfx.png create mode 100644 graphics/blind_gfx0.grit create mode 100644 graphics/blind_gfx0.png create mode 100644 graphics/blind_gfx1.grit create mode 100644 graphics/blind_gfx1.png create mode 100644 graphics/blind_gfx10.grit create mode 100644 graphics/blind_gfx10.png create mode 100644 graphics/blind_gfx11.grit create mode 100644 graphics/blind_gfx11.png create mode 100644 graphics/blind_gfx12.grit create mode 100644 graphics/blind_gfx12.png create mode 100644 graphics/blind_gfx13.grit create mode 100644 graphics/blind_gfx13.png create mode 100644 graphics/blind_gfx14.grit create mode 100644 graphics/blind_gfx14.png create mode 100644 graphics/blind_gfx15.grit create mode 100644 graphics/blind_gfx15.png create mode 100644 graphics/blind_gfx16.grit create mode 100644 graphics/blind_gfx16.png create mode 100644 graphics/blind_gfx17.grit create mode 100644 graphics/blind_gfx17.png create mode 100644 graphics/blind_gfx2.grit create mode 100644 graphics/blind_gfx2.png create mode 100644 graphics/blind_gfx3.grit create mode 100644 graphics/blind_gfx3.png create mode 100644 graphics/blind_gfx4.grit create mode 100644 graphics/blind_gfx4.png create mode 100644 graphics/blind_gfx5.grit create mode 100644 graphics/blind_gfx5.png create mode 100644 graphics/blind_gfx6.grit create mode 100644 graphics/blind_gfx6.png create mode 100644 graphics/blind_gfx7.grit create mode 100644 graphics/blind_gfx7.png create mode 100644 graphics/blind_gfx8.grit create mode 100644 graphics/blind_gfx8.png create mode 100644 graphics/blind_gfx9.grit create mode 100644 graphics/blind_gfx9.png delete mode 100644 graphics/boss_blind_gfx.grit delete mode 100644 graphics/boss_blind_gfx.png delete mode 100644 graphics/small_blind_gfx.grit delete mode 100644 graphics/small_blind_gfx.png create mode 100644 include/blind_gfx.h create mode 100644 include/def_blind_gfx_table.h diff --git a/graphics/big_blind_gfx.grit b/graphics/big_blind_gfx.grit deleted file mode 100644 index 176fddf..0000000 --- a/graphics/big_blind_gfx.grit +++ /dev/null @@ -1 +0,0 @@ --gB4 -Mw4 -Mh4 -p! \ No newline at end of file diff --git a/graphics/big_blind_gfx.png b/graphics/big_blind_gfx.png deleted file mode 100644 index b424f7d5100e0cf64799ce7126261f0fc1dd013f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 425 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%C&rs6b?Si}mUKs7M+SzC z{oH>NSwSk3J%W507^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+10g0sLQ zvY3HEPZ@+6E0)@q0R`DhJbhi+UvlxW>a*W>3`tRxD7!q;#ZP;zzW&@rri}Mb0 zq)a$-SmBJYp}UdOvjy>vSI(X;REg45S3DqiXD&Z8hiK02vS-)6)w&BXWgofs`_0kU zySiEv_&<6mdYrU8qNx}oXwkJN{K)Dp8Eg0U^%^Fu-TUqPE|yi#?A#N2Jl9pe@18ta zB;a+^mDE57-RfJPVqEsd27EA>rS#y+P7OcCvv%|PYt*h3%EX_0Dr}wA3 z7934{ReM3WyDI669gD?tgO&?6Rk|FC4aI!_(|Iz*SNxuqcjSh}JNtcYQLl?5#WpU^ zV^nr2I61lACF->>LxZx)vE!=x|Ae=3OcV%b4N%nd=ulTvQ>$ak|I)H=(&pp*ar diff --git a/graphics/blind_gfx0.grit b/graphics/blind_gfx0.grit new file mode 100644 index 0000000..8c324f6 --- /dev/null +++ b/graphics/blind_gfx0.grit @@ -0,0 +1 @@ +-gB4 -Mw4 -Mh4 -pn 16 \ No newline at end of file diff --git a/graphics/blind_gfx0.png b/graphics/blind_gfx0.png new file mode 100644 index 0000000000000000000000000000000000000000..851e9b2edd3c820a4fc687050f0a0ea2223b1402 GIT binary patch literal 393 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3-p)I`?e@QjEnx?oJHr&dIz4ats1|LR^9L z|NsAW92&Fg_gjUoX2@R4;S|MSnGF=T@%CF;rSp78)`LY>OS2h*oFs~!81BBi+%2f`J%G}Hb02Dlq?<+x+(3I zo{RELr@&dNQqOg!Ib4j|K1WoTUj&Hc!dXAn@=8r`XZ|!>(c7zNZY6(HkeB|iot&Ej zos;@{YV;q=gh@2LUc&D9ve7}><6X>kNjK)yy9@tDOqk>F-tmF=9rKEc6MqFA4=COL zHfdjb$A>xBe}3N8c=e_>$2)ubY6i#stlz^$R4TZ)4nDX`A!l=Xa(g?TfZ5 z`k%8@{bVY06M4A|6mIbF6q_jcABj77LO68&3hVcx>@|UN3WGBi8HRdW{C_?_{3k=! Xb@39vh21ScZ!>th`njxgN@xNA&_tiQ literal 0 HcmV?d00001 diff --git a/graphics/blind_gfx1.grit b/graphics/blind_gfx1.grit new file mode 100644 index 0000000..8c324f6 --- /dev/null +++ b/graphics/blind_gfx1.grit @@ -0,0 +1 @@ +-gB4 -Mw4 -Mh4 -pn 16 \ No newline at end of file diff --git a/graphics/blind_gfx1.png b/graphics/blind_gfx1.png new file mode 100644 index 0000000000000000000000000000000000000000..b48c5a7c897085e49ea045f8dfd6347ce30d5815 GIT binary patch literal 377 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3-p)I`?e@QjEnx?oJHr&dIz4ats1|LR^7# zl%hb3p~T+optVklQxrM86eWTLI6&f>3{#vK&Q)9PjpA7A#1LdC5T(d)|7y)zpqxNS zkY6yve^hWFpxYTJciYp&F~p|87PX zZieqq#OKuM_a~b$_dF|cI3Rohu1q_bRJt7bm-@F{q>)ix1AIJdLysC2k1=(Pgg&e IbxsLQ0Bvfa2LJ#7 literal 0 HcmV?d00001 diff --git a/graphics/blind_gfx10.grit b/graphics/blind_gfx10.grit new file mode 100644 index 0000000..8c324f6 --- /dev/null +++ b/graphics/blind_gfx10.grit @@ -0,0 +1 @@ +-gB4 -Mw4 -Mh4 -pn 16 \ No newline at end of file diff --git a/graphics/blind_gfx10.png b/graphics/blind_gfx10.png new file mode 100644 index 0000000000000000000000000000000000000000..79e8ba09811cc77127575dc3c4dc79798ad8ded0 GIT binary patch literal 364 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3-p)I`?e@QjEnx?oJHr&dIz4ats1|LR^8g zv8{|-uxevpd`zC9QmcrDAH5?@7dYVeLp0b-RbO|#UB{(rY$% z)LgVfog(!-&DL%86neBP&(mj4l@k!X_@$Eb|5(JqZ)+2N`~47nVar$}-+KA|Nv^G? zX`yv_HVm~4S=@i7j0~p~7m-x>2 swLe4{7L_UWwQO|1l&);G{LlH^xOt|m#qoQlgM7%~>FVdQ&MBb@0PksH!T|GLuf6j4>4&f1fFeK;t-r(xNC}h#`2{ol zM+FB0x}AY?yFFbTLo9mVPIBZstiZ#PdsF<(r~mK6vNN1zR@E)2_M9TiCZfD4soC(S zkTLt?GM6)V=Ca7Mr+nCLu6Ez;?Zi?Rr4EM0OeduJT(k@rw#@h~oT+i-#Jsg?Laq~= zcGj@DCi2N87`rsz=CfdoeLb~denYujLtI0A!#jra9|9FV@kn3zY_9Uan_Tg;Z(P!FStzYXaEW^Sc$N2K8-IX|((%pfp`sQ0H^ literal 0 HcmV?d00001 diff --git a/graphics/blind_gfx14.grit b/graphics/blind_gfx14.grit new file mode 100644 index 0000000..8c324f6 --- /dev/null +++ b/graphics/blind_gfx14.grit @@ -0,0 +1 @@ +-gB4 -Mw4 -Mh4 -pn 16 \ No newline at end of file diff --git a/graphics/blind_gfx14.png b/graphics/blind_gfx14.png new file mode 100644 index 0000000000000000000000000000000000000000..59e87af84523bc7e0df4240fe1c3c88a35a8f99e GIT binary patch literal 343 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyjKx9jP7LeL$-D$|3<7*YT!FMx zbutiD?_Ca`!fe!KGcDNqCmyehd$fRsQoSMv= Tz*^^_4f3d`tDnm{r-UW|bytoF literal 0 HcmV?d00001 diff --git a/graphics/blind_gfx15.grit b/graphics/blind_gfx15.grit new file mode 100644 index 0000000..8c324f6 --- /dev/null +++ b/graphics/blind_gfx15.grit @@ -0,0 +1 @@ +-gB4 -Mw4 -Mh4 -pn 16 \ No newline at end of file diff --git a/graphics/blind_gfx15.png b/graphics/blind_gfx15.png new file mode 100644 index 0000000000000000000000000000000000000000..7333f01fae1c0a587218d72747e3da251e2db32b GIT binary patch literal 356 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyjKx9jP7LeL$-D$|j01c^T!D0U z&{`l`I^}&&@pB+q9Cgjfve-~F3Mggc?dPAIzF_s*E03Rk`1%bf0t6{P7fl9If+azI z!3_V=fPkpOLZIX!PZ!4!i{7`B0{IRba5y)A2oHMx@AzDvl~XSH>^|`4@`}3BhD*05 z`JcQkzOz~APsa{sfrZBzXIAy=9nB1zpUCgYVX5tKGq8CAm(QfyCw~>((-qTxY!GRh z@t(nDPnmjQEz5@zpeR4w%h%FF!wvc%n^B%@K4CN2H^uDo_ z7H(y~C~x{@`F^Eq3O(x^dQL=YFTBpc_|sf+TU%&D+0@zapH-R8hUB&ak SctM2{$fKUFelF{r5}E+PtBZyJ literal 0 HcmV?d00001 diff --git a/graphics/blind_gfx17.grit b/graphics/blind_gfx17.grit new file mode 100644 index 0000000..8c324f6 --- /dev/null +++ b/graphics/blind_gfx17.grit @@ -0,0 +1 @@ +-gB4 -Mw4 -Mh4 -pn 16 \ No newline at end of file diff --git a/graphics/blind_gfx17.png b/graphics/blind_gfx17.png new file mode 100644 index 0000000000000000000000000000000000000000..09a31559f858d3bd9a3fb21c64b357033ac9d2ff GIT binary patch literal 346 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyjKx9jP7LeL$-D$|3<7*YT!A!0 z^*JE2-1?tk&VPoU?+igL0$#;HVHi(`mI@7qh>e1{DlbPGg z*SBqYplN|mzsuD#8b2&19DM(5&QG(fK1ucl1x7d4f_??(mTFe!hU07xHIh=~ibW?T z$#9i9uMN1pvqLAbigg=z4x=^0vrSs>9QHM&Fz#fskt$%d4WG!nGnAofH)njdz`_sJ z`?MN38{8eke%$k1&&pCctC+juf#{aFcg|;{AD@3Kt@`Q2pZIt2+>f^>TsMrAuyFKyY|6ScJ1X^N9!P>^P}ui@fdKskYu zAirRS|ESAy|J!g(H1u!M- zY2rR0`A0aQi9zz&QN|7bXsIvIZw#KUelF{r5}E+QSCmTt literal 0 HcmV?d00001 diff --git a/graphics/blind_gfx3.grit b/graphics/blind_gfx3.grit new file mode 100644 index 0000000..8c324f6 --- /dev/null +++ b/graphics/blind_gfx3.grit @@ -0,0 +1 @@ +-gB4 -Mw4 -Mh4 -pn 16 \ No newline at end of file diff --git a/graphics/blind_gfx3.png b/graphics/blind_gfx3.png new file mode 100644 index 0000000000000000000000000000000000000000..fa5ca4f478ca33c8bc505649aae35293659d48b7 GIT binary patch literal 380 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3-p)I`?e@QjEnx?oJHr&dIz4ats1|LR^8g zX10^%l&I=+bAt9(TW-x(Om>n;wgif=UHjk5Yim!>_w3~FL0-=dEsHf3t0TVo$O7dA zN`m}?8UCY!0|DL6K)HLKE{-7{oo}yr^Bp$eUG`6)EV>ic)cPJ>`$0NEE}7wna*IRdyN4VH3YcR) zi!q&Lye&J2@nEn8LkjC}xdpSfGhC>RJh-pZGN3$x>(%y#w0AA9ew!!M_gWe#HL#Wn zzIf(#gRg*l#lMLczBA5JyLIonOMtmcO!^}~v$kWN&-3s7nacm$R$O*}heQp~rwpF1 KelF{r5}E*KTb{=N literal 0 HcmV?d00001 diff --git a/graphics/blind_gfx4.grit b/graphics/blind_gfx4.grit new file mode 100644 index 0000000..8c324f6 --- /dev/null +++ b/graphics/blind_gfx4.grit @@ -0,0 +1 @@ +-gB4 -Mw4 -Mh4 -pn 16 \ No newline at end of file diff --git a/graphics/blind_gfx4.png b/graphics/blind_gfx4.png new file mode 100644 index 0000000000000000000000000000000000000000..9d1b374afb424fe058e2b85966a2cd93a02451a4 GIT binary patch literal 357 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3-p)I`?e@QjEnx?oJHr&dIz4ats1|LR^7# zdST#%xrL{$ui1He(%NG^LCId#JyAgMDZ6j!r}pPAK5N&ySFw1lgj2GFQCKcw7R7%Y_gBJs-_E+rX^M_3*Svg(WZS zwE{YG)-29iz0NA_-wUp!So2uFo;?a~aRM{myS&kT%l>h3{It~uzv4J}e)1fcq5Ys` z^Zla6k1vH8cFX58a9qe=d0>J)!=G>u25){vhL6VoSht8|JdTN}xN}0~!f%y?`~YzV zeTfSXVrq8BZ`jW~$KUKAqhG*+oyCpyjZFLYGag}8*mL|weCrKiQ(a oRQ?pxS$oy6bDd57_jecf&A2Zi|4N+uE6_^}p00i_>zopr09Z4Y&;S4c literal 0 HcmV?d00001 diff --git a/graphics/blind_gfx5.grit b/graphics/blind_gfx5.grit new file mode 100644 index 0000000..8c324f6 --- /dev/null +++ b/graphics/blind_gfx5.grit @@ -0,0 +1 @@ +-gB4 -Mw4 -Mh4 -pn 16 \ No newline at end of file diff --git a/graphics/blind_gfx5.png b/graphics/blind_gfx5.png new file mode 100644 index 0000000000000000000000000000000000000000..182e8502b7bec2372aec22a0af65e20bdfe9ba56 GIT binary patch literal 367 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3-p)I`?e@QjEnx?oJHr&dIz4ats1|LR^7# zOSaP13A&%proTU6^L(pfc9dpMHV05V-8i_%t?*RK`kgV;);hHW8G0ovdYunaasm+u6J&6P|nj7!euFsR#z zN3g64wqR&tkUD-|*nlbO0B1<=2KE&GnpWNm=NxPqni`qRHImO|FeWnW$Y)@%WcVi* zw&3Ui-5=!vXXbq8zH{J{PH5?coyR&&AO1Nzd;cfKx4R_d9|f780(y?Y)78&qol`;+0OB;1T>t<8 literal 0 HcmV?d00001 diff --git a/graphics/blind_gfx6.grit b/graphics/blind_gfx6.grit new file mode 100644 index 0000000..8c324f6 --- /dev/null +++ b/graphics/blind_gfx6.grit @@ -0,0 +1 @@ +-gB4 -Mw4 -Mh4 -pn 16 \ No newline at end of file diff --git a/graphics/blind_gfx6.png b/graphics/blind_gfx6.png new file mode 100644 index 0000000000000000000000000000000000000000..6ce085695268fafabe5d1fc6688d4b1b82615701 GIT binary patch literal 387 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3-p)I`?e@QjEnx?oJHr&dIz4ats1|LR^7# zUQN@ql^d@-e}C-3>%G_RMP(Of7gqzt{V0%07X0$(&1dt#$k5%mNP02)Oq?X5r(euhs{$TV(^JEe`x; z@6oofXEb+En4Ry?U~_)t_Vrc~8_K7=@-BR08Ffw3vY0_2XlDag8Bk83 zB*-tA;Xf)k5YX)ml)LQd;uzx5`F6@dz7_)x7tJccKmXsGa&4R9bSdroix`ucd!}!T zU^JP{vT1|L>g~DHRk)r73u$Z3(*Pn7{iQ1oede#YBY5?zwNp0 zlphf1uVCQAA+`R!%*U_%P2Lc+lE)Q_%ZhFXbjpd+7 z&jQIF24DY!4hSoVR5%hnb4&50@wvh+$e^a6^zMFocDrA%J4s9;h{R7$!cgrX z?r`7F;bP0l+XkK=!~G- literal 0 HcmV?d00001 diff --git a/graphics/blind_gfx9.grit b/graphics/blind_gfx9.grit new file mode 100644 index 0000000..8c324f6 --- /dev/null +++ b/graphics/blind_gfx9.grit @@ -0,0 +1 @@ +-gB4 -Mw4 -Mh4 -pn 16 \ No newline at end of file diff --git a/graphics/blind_gfx9.png b/graphics/blind_gfx9.png new file mode 100644 index 0000000000000000000000000000000000000000..3c2398d8d0b8e00420f05dea102f3c1f7d979826 GIT binary patch literal 363 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3-p)I`?e@QjEnx?oJHr&dIz4ats1|LR^8g zT9}S;iB0Z?GUr+TnmvY!UYY_<5$w|hv!(^HeO#K~dTqD%>;mSF{mg&a)eP>f z`CZ(+vsp}~LB64snfJ-p)FYf63qM}J&gGTB@R4Uh5yK7X9}PCkm`_N1D4cx#d3HtI zUC~vnY5!Pr%mo_6*d`p=V`Vi;C%b=>@-^H|$*ecJqOTx6CS@D!18J)U@y3 u_g(ej714*+J707j3($P{=j7zYdl)%ahNSwSk3J%W507^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+10g0sLQ zvY3HEPZ@+6E0)@q0R`DhJbhi+UvlxW>Pzi&?E#v>@WRu@F(l&f+i7=sTNDIZ%6nr2 znnaRpMVxHgtQN4mdJuQ+h;jD@onyv{a(@%;jzuy%IUbuaWq0~oR{<{XV~Q6ed{wt7K39;Zi%Q> zL`>dNG3A>`+{6QCbi;l1cQJm+v*CO&hk0p8;l7>E&h7li8Sv3txU!CC?{|shH@h-= z1owRZG0*VNrDesE(fjn%zu#opv03k@`JV|{YlHJt-rumTRJs(U&cMKTA}(p&&!;mt pu(>3~uvjz)Op@T|<>md`Yj;DkzB*8NSwSk3J%W507^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+10g0sLQ zvY3HEPZ@+6E0)@q0R`DhJbhi+UvlxW>gj)cTlowq^w-nHF(l&f+iCB4TNHSXMqevn zk!-1yIa1kCe1PN3!`e@eOrQE|TD}*$Cmy)yeRxH$Ldcff+cRh1{x0jNxkmE1#Af~V zuUD}hlzTi;!Q-szF_{h#Cij`&og{u8sOG=-`}>c&Tv_jw9k1pVM+!fWxu|n2;?0~_ zTmg3zO{S(X?s(;`CgQQ1i%m{U+NpDk#bWc|M@#ch8N|ok{O&* zyxF>Ylp0pw-!F7XfN9y3uB)C?gPH`G{`pH^3SDq@` #include +static const unsigned int* blind_gfxTiles[] = { +#define DEF_BLIND_GFX(idx) blind_gfx##idx##Tiles, +#include "../include/def_blind_gfx_table.h" +#undef DEF_BLIND_GFX +}; + +static const unsigned short* blind_gfxPal[] = { +#define DEF_BLIND_GFX(idx) blind_gfx##idx##Pal, +#include "../include/def_blind_gfx_table.h" +#undef DEF_BLIND_GFX +}; + +// Bitfields storing blinds we have yet to beat during the current run +static List unbeaten_boss_blinds; +static List unbeaten_showdown_blinds; + // Maps the ante number to the base blind requirement for that ante. // The game starts at ante 1 which is at index 1 for base requirement 300. // Ante 0 is also there in case it is ever reached. static const u32 ante_lut[] = {100, 300, 800, 2000, 5000, 11000, 20000, 35000, 50000}; -// 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}; -// This variable is temporary, each boss blind will have its own unique palette -static const u16 boss_blind_token_palette[PAL_ROW_LEN] = - {0x0000, 0x2CC9, 0x3D0D, 0x5E14, 0x5171, 0x4D0F, 0x2CC8, 0x3089}; - // clang-format off static Blind _blind_type_map[BLIND_TYPE_MAX] = { -#define BLIND_INFO(NAME, name, multi, _reward) \ - { \ - .type = BLIND_TYPE_##NAME, \ - .gfx_info = \ - { \ - .tiles = name##_blind_gfxTiles, \ - .palette = name##_blind_token_palette, \ - .tid = NAME##_BLIND_TID, \ - .pb = NAME##_BLIND_PB, \ - }, \ - .score_req_multipler = multi, \ - .reward = _reward, \ -}, - BLIND_TYPE_INFO_TABLE -#undef BLIND_INFO + {BLIND_TYPE_SMALL, FIX_ONE, 3}, + {BLIND_TYPE_BIG, (FIX_ONE * 3) / 2, 4}, + {BLIND_TYPE_HOOK, FIX_ONE * 2, 5}, + {BLIND_TYPE_OX, FIX_ONE * 2, 5}, + {BLIND_TYPE_HOUSE, FIX_ONE * 2, 5}, + {BLIND_TYPE_WALL, FIX_ONE * 2, 5}, // x4 score requirement will be part of the effect + {BLIND_TYPE_WHEEL, FIX_ONE * 2, 5}, + {BLIND_TYPE_ARM, FIX_ONE * 2, 5}, + {BLIND_TYPE_CLUB, FIX_ONE * 2, 5}, + {BLIND_TYPE_FISH, FIX_ONE * 2, 5}, + {BLIND_TYPE_PSYCHIC, FIX_ONE * 2, 5}, + {BLIND_TYPE_GOAD, FIX_ONE * 2, 5}, + {BLIND_TYPE_WATER, FIX_ONE * 2, 5}, + {BLIND_TYPE_WINDOW, FIX_ONE * 2, 5}, + {BLIND_TYPE_MANACLE, FIX_ONE * 2, 5}, + {BLIND_TYPE_EYE, FIX_ONE * 2, 5}, + {BLIND_TYPE_MOUTH, FIX_ONE * 2, 5}, + {BLIND_TYPE_PLANT, FIX_ONE * 2, 5}, + {BLIND_TYPE_SERPENT, FIX_ONE * 2, 5}, + {BLIND_TYPE_PILLAR, FIX_ONE * 2, 5}, + {BLIND_TYPE_NEEDLE, FIX_ONE * 2, 5}, // Same as the Wall with normal requirement + {BLIND_TYPE_HEAD, FIX_ONE * 2, 5}, + {BLIND_TYPE_TOOTH, FIX_ONE * 2, 5}, + {BLIND_TYPE_FLINT, FIX_ONE * 2, 5}, + {BLIND_TYPE_MARK, FIX_ONE * 2, 5}, + {BLIND_TYPE_ACORN, FIX_ONE * 2, 8}, + {BLIND_TYPE_LEAF, FIX_ONE * 2, 8}, + {BLIND_TYPE_VESSEL, FIX_ONE * 2, 8}, // Same as the Wall with x6 requirement + {BLIND_TYPE_HEART, FIX_ONE * 2, 8}, + {BLIND_TYPE_BELL, FIX_ONE * 2, 8} }; // clang-format on -static void s_blind_gfx_init(enum BlindType type); - -GBAL_UNUSED -void blind_set_boss_graphics(const unsigned int* tiles, const u16* palette) -{ - // TODO: This function is unused and not fully fleshed out. - // We need to support more boss blind graphics in the future. - // The idea here is that we can call this function to set the boss up to - // render new tiles - // - // This will eventually be in it's own map mapping graphic data to - // boss types. - - _blind_type_map[BLIND_TYPE_BOSS].gfx_info.tiles = tiles; - _blind_type_map[BLIND_TYPE_BOSS].gfx_info.palette = palette; - s_blind_gfx_init(BLIND_TYPE_BOSS); -} - void blind_init() { - for (int i = 0; i < BLIND_TYPE_MAX; i++) - { - s_blind_gfx_init(i); - } + // Set up the palette used by normal blind tokens. + // We will never need to edit it ever again. + memcpy16(&pal_obj_bank[NORMAL_BLIND_PB], blind_gfxPal[0], NUM_ELEM_IN_ARR(blind_gfx0Pal)); return; } @@ -85,34 +88,156 @@ int blind_get_reward(enum BlindType type) return _blind_type_map[type].reward; } -u16 blind_get_color(enum BlindType type, enum BlindColorIndex index) +// Fills the unbeaten boss blinds lists +// This must be called at the beginning of a run +void init_unbeaten_blinds_list(bool showdown) { - return _blind_type_map[type].gfx_info.palette[index]; + // create the lists when calling for the first time + static bool init = false; + if (!init) + { + init = true; + unbeaten_showdown_blinds = list_create(); + unbeaten_boss_blinds = list_create(); + } + + List* p_unbeaten_blinds = showdown ? &unbeaten_showdown_blinds : &unbeaten_boss_blinds; + + // empty the list just to be sure + list_clear(p_unbeaten_blinds); + + int lower_blind = showdown ? BLIND_TYPE_SHOWDOWN : BLIND_TYPE_BOSS; + int upper_blind = showdown ? BLIND_TYPE_MAX - 1 : BLIND_TYPE_SHOWDOWN - 1; + + for (int i = lower_blind; i <= upper_blind; i++) + { + list_push_back(p_unbeaten_blinds, &_blind_type_map[i]); + } } -Sprite* blind_token_new(enum BlindType type, int x, int y, int sprite_index) +enum BlindType roll_blind_type(bool showdown) { - u16 a0 = ATTR0_SQUARE | ATTR0_4BPP; - u16 a1 = ATTR1_SIZE_32x32; - u32 tid = _blind_type_map[type].gfx_info.tid, pb = _blind_type_map[type].gfx_info.pb; + List* p_unbeaten_blinds = showdown ? &unbeaten_showdown_blinds : &unbeaten_boss_blinds; - Sprite* sprite = sprite_new(a0, a1, tid, pb, sprite_index); + // Fill the list with all blinds if it is empty + // (happens on startup or if we have beaten all blinds) + if (list_is_empty(p_unbeaten_blinds)) + { + init_unbeaten_blinds_list(showdown); + } + // roll a random blind among the unbeaten ones + int random_blind_idx = rand() % list_get_len(p_unbeaten_blinds); + Blind* random_blind = list_get_at_idx(p_unbeaten_blinds, random_blind_idx); + + return random_blind->type; +} + +void set_blind_beaten(enum BlindType type) +{ + bool showdown = (type >= BLIND_TYPE_SHOWDOWN); + List* p_unbeaten_blinds = showdown ? &unbeaten_showdown_blinds : &unbeaten_boss_blinds; + + // find the beaten blind idx in the list + int beaten_idx = 0; + Blind* beaten_blind = NULL; + ListItr itr = list_itr_create(p_unbeaten_blinds); + + while ((beaten_blind = list_itr_next(&itr))) + { + if (beaten_blind->type == type) + { + break; + } + beaten_idx++; + } + + if (beaten_idx < list_get_len(p_unbeaten_blinds)) + { + list_remove_at_idx(p_unbeaten_blinds, beaten_idx); + } +} + +static u32 get_blind_pb(enum BlindType type) +{ + return (type <= BLIND_TYPE_BIG) ? NORMAL_BLIND_PB : BOSS_BLIND_PB; +} + +static u32 get_blind_spritesheet_idx(enum BlindType type) +{ + // See comment below in blind_get_color why we differenciate before/after the Mark + return (type < BLIND_TYPE_MARK) + ? type / BLIND_TOKENS_PER_SPRITESHEET + : BLIND_TYPE_MARK / BLIND_TOKENS_PER_SPRITESHEET + type - BLIND_TYPE_MARK; +} + +u16 blind_get_color(enum BlindType type, enum BlindColorIndex index) +{ + // Do a little translation of palette idx -> custom array idx + // All blinds before the Mark are arranged in pairs with their palettte split in two + // | XX | 1 | 2 | 3 | 4 | 5 | 6 | 7 | -> first sprite + // | XX | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -> second sprite + // so we need to offset the color indices by 8 for blinds with an odd type + // From the Mark onwards, all sprites are alone in their spritesheet, so no need to offset + u32 color_idx = index + ((type < BLIND_TYPE_MARK) + ? BLIND_TOKEN_PALETTE_SIZE * (type % BLIND_TOKENS_PER_SPRITESHEET) + : 0); + return blind_gfxPal[get_blind_spritesheet_idx(type)][color_idx]; +} + +void apply_blind_colors(enum BlindType type) +{ + // keep track of active boss blind spritesheet to copy colors only when changing + static u32 active_boss_spritesheet = BLIND_TYPE_MAX; + u32 new_spritesheet = get_blind_spritesheet_idx(type); + + // No need to update normal blind palette + if (type < BLIND_TYPE_BOSS || active_boss_spritesheet == new_spritesheet) + { + return; + } + + active_boss_spritesheet = new_spritesheet; + + // Just copy the palette as is to the sprite palette bank + memcpy16( + &pal_obj_bank[BOSS_BLIND_PB], + blind_gfxPal[active_boss_spritesheet], + NUM_ELEM_IN_ARR(blind_gfx0Pal) + ); +} + +static u32 get_layer_tile_index(int layer) +{ + // All Blind sprites are stored sequentially and correspond to their IDs + return (BLIND_BASE_LAYER + layer) * BLIND_SPRITE_OFFSET; +} + +void apply_blind_tiles(enum BlindType type, int layer) +{ + u32 spritesheet_idx = get_blind_spritesheet_idx(type); + u32 sprite_idx = (type < BLIND_TYPE_MARK) ? type % BLIND_TOKENS_PER_SPRITESHEET : 0; + memcpy32( + &tile_mem[TILE_MEM_OBJ_CHARBLOCK0_IDX][get_layer_tile_index(layer)], + &blind_gfxTiles[spritesheet_idx][sprite_idx * BLIND_SPRITE_COPY_SIZE], + BLIND_SPRITE_COPY_SIZE + ); + + apply_blind_colors(type); +} + +Sprite* blind_token_new(enum BlindType type, int x, int y, int layer) +{ + apply_blind_tiles(type, layer); + + Sprite* sprite = sprite_new( + ATTR0_SQUARE | ATTR0_4BPP | ATTR0_AFF, + ATTR1_SIZE_32x32, + get_layer_tile_index(layer), + get_blind_pb(type), + BLIND_BASE_LAYER + layer + ); sprite_position(sprite, x, y); return sprite; } - -static void s_blind_gfx_init(enum BlindType type) -{ - // TODO: Re-add grit copy. You need to decouple the blind graphics first. - // This will allow this function to change the boss graphics info - // GRIT_CPY(&tile_mem[TILE_MEM_OBJ_CHARBLOCK0_IDX][_blind_type_map[type].pal_info.tid], tiles); - BlindGfxInfo* p_gfx = &_blind_type_map[type].gfx_info; - memcpy32( - &tile_mem[TILE_MEM_OBJ_CHARBLOCK0_IDX][p_gfx->tid], - p_gfx->tiles, - BLIND_SPRITE_COPY_SIZE - ); - memcpy16(&pal_obj_bank[p_gfx->pb], p_gfx->palette, PAL_ROW_LEN); -} diff --git a/source/game.c b/source/game.c index 247ad8b..7e19e39 100644 --- a/source/game.c +++ b/source/game.c @@ -178,6 +178,16 @@ enum BlindSelectStates BLIND_SELECT_MAX }; +// The sprites that display the blinds when in "GAME_BLIND_SELECT" state +// There are only 3 blinds per Ante, so we don't need more sprites than that +enum BlindTokens +{ + SMALL_BLIND, + BIG_BLIND, + BOSS_BLIND, + NUM_BLINDS_PER_ANTE +}; + typedef struct { u32 chips; @@ -223,7 +233,7 @@ static void game_blind_select_start_anim_seq(void); static void game_blind_select_handle_input(void); static void game_blind_select_selected_anim_seq(void); static void game_blind_select_display_blind_panel(void); -static Rect game_blind_select_get_req_score_rect(enum BlindType blind); +static Rect game_blind_select_get_req_score_rect(enum BlindTokens blind); static void game_blind_select_print_blinds_reqs_and_rewards(void); static void game_round_end_start(void); static void game_round_end_start_expand_popup(void); @@ -565,14 +575,16 @@ static Sprite* playing_blind_token = NULL; // The sprite that displays the blind when in "GAME_ROUND_END" state static Sprite* round_end_blind_token = NULL; -// The sprites that display the blinds when in "GAME_BLIND_SELECT" state -static Sprite* blind_select_tokens[BLIND_TYPE_MAX] = {NULL}; +static Sprite* blind_select_tokens[NUM_BLINDS_PER_ANTE] = {NULL}; -static int current_blind = BLIND_TYPE_SMALL; +static bool boss_rolled_this_ante = false; +// Will be rolled later, just giving it a valid value +static enum BlindType next_boss_blind = BLIND_TYPE_HOOK; +static enum BlindType current_blind = BLIND_TYPE_SMALL; // The current state of the blinds, this is used to determine what the game is doing at any given // time -static enum BlindState blinds_states[BLIND_TYPE_MAX] = { +static enum BlindState blinds_states[NUM_BLINDS_PER_ANTE] = { BLIND_STATE_CURRENT, BLIND_STATE_UPCOMING, BLIND_STATE_UPCOMING @@ -730,6 +742,49 @@ static inline void jokers_available_to_shop_init(void) reset_shop_jokers(); } +static void reroll_boss_blind(bool no_tiles) +{ + // Showdown blinds only show up on ante 8, 16, etc... + next_boss_blind = roll_blind_type((ante % 8 == 0) && (ante > 0)); + if (!no_tiles) + { + apply_blind_tiles(next_boss_blind, BOSS_BLIND_TOKEN_LAYER); + } +} + +static void blind_tokens_init() +{ + reroll_boss_blind(true); + + sprite_destroy(&blind_select_tokens[SMALL_BLIND]); + sprite_destroy(&blind_select_tokens[BIG_BLIND]); + sprite_destroy(&blind_select_tokens[BOSS_BLIND]); + + blind_select_tokens[SMALL_BLIND] = blind_token_new( + BLIND_TYPE_SMALL, + CUR_BLIND_TOKEN_POS.x, + CUR_BLIND_TOKEN_POS.y, + SMALL_BLIND_TOKEN_LAYER + ); + blind_select_tokens[BIG_BLIND] = blind_token_new( + BLIND_TYPE_BIG, + CUR_BLIND_TOKEN_POS.x, + CUR_BLIND_TOKEN_POS.y, + BIG_BLIND_TOKEN_LAYER + ); + blind_select_tokens[BOSS_BLIND] = blind_token_new( + next_boss_blind, + CUR_BLIND_TOKEN_POS.x, + CUR_BLIND_TOKEN_POS.y, + BOSS_BLIND_TOKEN_LAYER + ); + + for (int i = 0; i < NUM_BLINDS_PER_ANTE; i++) + { + obj_hide(blind_select_tokens[i]->obj); + } +} + void game_init() { // Initialize all jokers list once @@ -754,28 +809,12 @@ void game_init() score = STARTING_SCORE; round = 0; - blind_select_tokens[BLIND_TYPE_SMALL] = blind_token_new( - BLIND_TYPE_SMALL, - CUR_BLIND_TOKEN_POS.x, - CUR_BLIND_TOKEN_POS.y, - MAX_SELECTION_SIZE + MAX_HAND_SIZE + 3 - ); - blind_select_tokens[BLIND_TYPE_BIG] = blind_token_new( - BLIND_TYPE_BIG, - CUR_BLIND_TOKEN_POS.x, - CUR_BLIND_TOKEN_POS.y, - MAX_SELECTION_SIZE + MAX_HAND_SIZE + 4 - ); - blind_select_tokens[BLIND_TYPE_BOSS] = blind_token_new( - BLIND_TYPE_BOSS, - CUR_BLIND_TOKEN_POS.x, - CUR_BLIND_TOKEN_POS.y, - MAX_SELECTION_SIZE + MAX_HAND_SIZE + 5 - ); + // Initialize/reset unbeaten Boss/Showdown Blinds so they are all available + init_unbeaten_blinds_list(false); + init_unbeaten_blinds_list(true); + boss_rolled_this_ante = false; - obj_hide(blind_select_tokens[BLIND_TYPE_SMALL]->obj); - obj_hide(blind_select_tokens[BLIND_TYPE_BIG]->obj); - obj_hide(blind_select_tokens[BLIND_TYPE_BOSS]->obj); + blind_tokens_init(); } static inline void discarded_jokers_update_loop(void) @@ -1458,12 +1497,10 @@ void change_background_legacy(enum BackgroundId id) { main_bg_se_copy_rect(BIG_BLIND_TITLE_SRC_RECT, TOP_LEFT_BLIND_TITLE_POINT); } - else if (current_blind == BLIND_TYPE_BOSS) + else if (current_blind > BLIND_TYPE_BIG) { main_bg_se_copy_rect(BOSS_BLIND_TITLE_SRC_RECT, TOP_LEFT_BLIND_TITLE_POINT); - - affine_background_set_color( - blind_get_color(BLIND_TYPE_BOSS, BLIND_SHADOW_COLOR_INDEX) + affine_background_set_color(blind_get_color(current_blind, BLIND_SHADOW_COLOR_INDEX) ); } @@ -1554,7 +1591,16 @@ void change_background_legacy(enum BackgroundId id) } else if (id == BG_BLIND_SELECT) { - for (int i = 0; i < BLIND_TYPE_MAX; i++) + // If this is the first time we see this menu this Ante, roll a boss blind + // This check is there for future safety, if we have any kind of pause menu + // so we don't reroll the boss blind every time this menu is opened + if (!boss_rolled_this_ante) + { + boss_rolled_this_ante = true; + reroll_boss_blind(false); + } + + for (int i = 0; i < NUM_BLINDS_PER_ANTE; i++) { obj_unhide(blind_select_tokens[i]->obj, 0); } @@ -1563,9 +1609,9 @@ void change_background_legacy(enum BackgroundId id) // is shifted down by const int default_y = 89 + (TILE_SIZE * 12); // TODO refactor magic numbers '80/120/160' into a map to loop with - sprite_position(blind_select_tokens[BLIND_TYPE_SMALL], 80, default_y); - sprite_position(blind_select_tokens[BLIND_TYPE_BIG], 120, default_y); - sprite_position(blind_select_tokens[BLIND_TYPE_BOSS], 160, default_y); + sprite_position(blind_select_tokens[SMALL_BLIND], 80, default_y); + sprite_position(blind_select_tokens[BIG_BLIND], 120, default_y); + sprite_position(blind_select_tokens[BOSS_BLIND], 160, default_y); toggle_windows(false, true); @@ -1576,12 +1622,12 @@ void change_background_legacy(enum BackgroundId id) // Copy boss blind colors to blind select palette memset16( &pal_bg_mem[1], - blind_get_color(BLIND_TYPE_BOSS, BLIND_BACKGROUND_MAIN_COLOR_INDEX), + blind_get_color(next_boss_blind, BLIND_BACKGROUND_MAIN_COLOR_INDEX), 1 ); memset16( &pal_bg_mem[7], - blind_get_color(BLIND_TYPE_BOSS, BLIND_BACKGROUND_SHADOW_COLOR_INDEX), + blind_get_color(next_boss_blind, BLIND_BACKGROUND_SHADOW_COLOR_INDEX), 1 ); @@ -1602,7 +1648,7 @@ void change_background_legacy(enum BackgroundId id) 1 ); - for (int i = 0; i < BLIND_TYPE_MAX; i++) + for (int i = 0; i < NUM_BLINDS_PER_ANTE; i++) { Rect curr_blind_rect = SINGLE_BLIND_SELECT_RECT; @@ -1643,7 +1689,7 @@ void change_background_legacy(enum BackgroundId id) { y_from = 31; } - else if (i == BLIND_TYPE_BOSS) + else if (i > BLIND_TYPE_BIG) { x_from = x_to; y_from = 30; @@ -1888,18 +1934,28 @@ static int deck_get_max_size(void) static void increment_blind(enum BlindState increment_reason) { - current_blind++; - if (current_blind >= BLIND_TYPE_MAX) + // cannot do blind++ anymore, we need to go SMALL->BIG->next_boss->SMALL... + switch (current_blind) { - current_blind = 0; - blinds_states[0] = BLIND_STATE_CURRENT; // Reset the blinds to the first one - blinds_states[1] = BLIND_STATE_UPCOMING; // Set the next blind to upcoming - blinds_states[2] = BLIND_STATE_UPCOMING; // Set the next blind to upcoming - } - else - { - blinds_states[current_blind] = BLIND_STATE_CURRENT; - blinds_states[current_blind - 1] = increment_reason; + // defeated small blind: go to big + case BLIND_TYPE_SMALL: + current_blind = BLIND_TYPE_BIG; + blinds_states[SMALL_BLIND] = increment_reason; + blinds_states[BIG_BLIND] = BLIND_STATE_CURRENT; + break; + // defeated big blind: go to next boss + case BLIND_TYPE_BIG: + current_blind = next_boss_blind; + blinds_states[BIG_BLIND] = increment_reason; + blinds_states[BOSS_BLIND] = BLIND_STATE_CURRENT; + break; + // defeated a boss: reset everything + default: + current_blind = BLIND_TYPE_SMALL; + blinds_states[SMALL_BLIND] = BLIND_STATE_CURRENT; // Reset the blinds to the first one + blinds_states[BIG_BLIND] = BLIND_STATE_UPCOMING; // Set the next blind to upcoming + blinds_states[BOSS_BLIND] = BLIND_STATE_UPCOMING; // Set the next blind to upcoming + break; } } @@ -1920,22 +1976,24 @@ static void game_round_on_init(GameVariables* vars) cards_drawn = 0; hand_selections = 0; + sprite_destroy(&playing_blind_token); playing_blind_token = blind_token_new( current_blind, CUR_BLIND_TOKEN_POS.x, CUR_BLIND_TOKEN_POS.y, - MAX_SELECTION_SIZE + MAX_HAND_SIZE + 1 + PLAYING_BLIND_TOKEN_LAYER ); // Create the blind token sprite at the top left corner // TODO: Hide blind token and display it after sliding blind rect animation // if (playing_blind_token != NULL) //{ // obj_hide(playing_blind_token->obj); // Hide the blind token sprite for now //} + sprite_destroy(&round_end_blind_token); round_end_blind_token = blind_token_new( current_blind, 81, 86, - MAX_SELECTION_SIZE + MAX_HAND_SIZE + 2 + ROUND_END_BLIND_TOKEN_LAYER ); // Create the blind token sprite for round end if (round_end_blind_token != NULL) @@ -2364,11 +2422,15 @@ static inline void game_playing_handle_round_over(void) if (score >= blind_get_requirement(current_blind, ante)) { - if (current_blind == BLIND_TYPE_BOSS) + if (current_blind > BLIND_TYPE_BIG) { if (ante < MAX_ANTE) { display_ante(++ante); + + // mark current boss blind as beaten and allow for reroll + set_blind_beaten(next_boss_blind); + boss_rolled_this_ante = false; } else { @@ -3590,7 +3652,7 @@ static void game_round_end_display_finished_blind() int current_ante = ante; // Beating the boss blind increases the ante, so we need to display the previous ante value - if (current_blind == BLIND_TYPE_BOSS) + if (current_blind > BLIND_TYPE_BIG) current_ante--; Rect blind_req_rect = ROUND_END_BLIND_REQ_RECT; @@ -4559,7 +4621,7 @@ static void game_blind_select_on_update(GameVariables* vars) static inline void game_blind_select_erase_blind_reqs_and_rewards() { - for (enum BlindType curr_blind = 0; curr_blind < BLIND_TYPE_MAX; curr_blind++) + for (enum BlindTokens curr_blind = SMALL_BLIND; curr_blind < NUM_BLINDS_PER_ANTE; curr_blind++) { Rect blind_req_and_reward_rect = SINGLE_BLIND_SEL_REQ_SCORE_RECT; @@ -4579,7 +4641,25 @@ static inline void game_blind_select_erase_blind_reqs_and_rewards() } } -static Rect game_blind_select_get_req_score_rect(enum BlindType blind) +static enum BlindType get_blind_type_from_token(enum BlindTokens blind) +{ + enum BlindType blind_type; + switch (blind) + { + case SMALL_BLIND: + blind_type = BLIND_TYPE_SMALL; + break; + case BIG_BLIND: + blind_type = BLIND_TYPE_BIG; + break; + default: + blind_type = next_boss_blind; + break; + } + return blind_type; +} + +static Rect game_blind_select_get_req_score_rect(enum BlindTokens blind) { Rect blind_req_score_rect = SINGLE_BLIND_SEL_REQ_SCORE_RECT; @@ -4596,11 +4676,11 @@ static Rect game_blind_select_get_req_score_rect(enum BlindType blind) return blind_req_score_rect; } -static inline void game_blind_select_print_blind_req(enum BlindType blind) +static inline void game_blind_select_print_blind_req(enum BlindTokens blind) { Rect blind_req_score_rect = game_blind_select_get_req_score_rect(blind); - u32 blind_req = blind_get_requirement(blind, ante); + u32 blind_req = blind_get_requirement(get_blind_type_from_token(blind), ante); char blind_req_str_buff[UINT_MAX_DIGITS + 1]; truncate_uint_to_suffixed_str( @@ -4620,9 +4700,9 @@ static inline void game_blind_select_print_blind_req(enum BlindType blind) ); } -static inline void game_blind_select_print_blind_reward(enum BlindType blind) +static inline void game_blind_select_print_blind_reward(enum BlindTokens blind) { - int blind_reward = blind_get_reward(blind); + int blind_reward = blind_get_reward(get_blind_type_from_token(blind)); Rect blind_reward_rect = game_blind_select_get_req_score_rect(blind); // The reward is right below the score. @@ -4645,7 +4725,7 @@ static inline void game_blind_select_print_blind_reward(enum BlindType blind) static void game_blind_select_print_blinds_reqs_and_rewards(void) { - for (enum BlindType curr_blind = 0; curr_blind < BLIND_TYPE_MAX; curr_blind++) + for (enum BlindTokens curr_blind = 0; curr_blind < NUM_BLINDS_PER_ANTE; curr_blind++) { game_blind_select_print_blind_req(curr_blind); game_blind_select_print_blind_reward(curr_blind); @@ -4656,7 +4736,7 @@ static void game_blind_select_start_anim_seq() { main_bg_se_copy_rect_1_tile_vert(POP_MENU_ANIM_RECT, SCREEN_UP); - for (int i = 0; i < BLIND_TYPE_MAX; i++) + for (int i = 0; i < NUM_BLINDS_PER_ANTE; i++) { sprite_position( blind_select_tokens[i], @@ -4675,7 +4755,7 @@ static void game_blind_select_start_anim_seq() static void game_blind_select_handle_input() { - if (timer == TM_BLIND_SELECT_START && current_blind == BLIND_TYPE_BOSS) + if (timer == TM_BLIND_SELECT_START && current_blind > BLIND_TYPE_BIG) { selection_y = 0; } @@ -4685,7 +4765,7 @@ static void game_blind_select_handle_input() { selection_y = 0; } - else if (key_hit(KEY_DOWN) && current_blind != BLIND_TYPE_BOSS) + else if (key_hit(KEY_DOWN) && current_blind <= BLIND_TYPE_BIG) { selection_y = 1; } @@ -4701,7 +4781,7 @@ static void game_blind_select_handle_input() ++round; display_round(); } - else if (current_blind != BLIND_TYPE_BOSS) + else if (current_blind <= BLIND_TYPE_BIG) { play_sfx(SFX_BUTTON, MM_BASE_PITCH_RATE, BUTTON_SFX_VOLUME); increment_blind(BLIND_STATE_SKIPPED); @@ -4717,7 +4797,7 @@ static void game_blind_select_handle_input() main_bg_se_copy_rect_1_tile_vert(POP_MENU_ANIM_RECT, SCREEN_UP); } - for (int i = 0; i < BLIND_TYPE_MAX; i++) + for (int i = 0; i < NUM_BLINDS_PER_ANTE; i++) { sprite_position( blind_select_tokens[i], @@ -4760,7 +4840,7 @@ static void game_blind_select_selected_anim_seq() blinds_rect.top -= 1; // Because of the raised blind main_bg_se_move_rect_1_tile_vert(blinds_rect, SCREEN_DOWN); - for (int i = 0; i < BLIND_TYPE_MAX; i++) + for (int i = 0; i < NUM_BLINDS_PER_ANTE; i++) { sprite_position( blind_select_tokens[i], @@ -4771,7 +4851,7 @@ static void game_blind_select_selected_anim_seq() } else if (timer >= MENU_POP_OUT_ANIM_FRAMES) { - for (int i = 0; i < BLIND_TYPE_MAX; i++) + for (int i = 0; i < NUM_BLINDS_PER_ANTE; i++) { obj_hide(blind_select_tokens[i]->obj); } @@ -4987,9 +5067,9 @@ static void game_over_on_exit(GameVariables* vars) // show up on the next run. sprite_destroy(&playing_blind_token); sprite_destroy(&round_end_blind_token); - sprite_destroy(&blind_select_tokens[BLIND_TYPE_SMALL]); - sprite_destroy(&blind_select_tokens[BLIND_TYPE_BIG]); - sprite_destroy(&blind_select_tokens[BLIND_TYPE_BOSS]); + sprite_destroy(&blind_select_tokens[SMALL_BLIND]); + sprite_destroy(&blind_select_tokens[BIG_BLIND]); + sprite_destroy(&blind_select_tokens[BOSS_BLIND]); list_clear(&_owned_jokers_list); list_clear(&_discarded_jokers_list); diff --git a/source/joker.c b/source/joker.c index 0d7b77f..2b976f8 100644 --- a/source/joker.c +++ b/source/joker.c @@ -179,7 +179,7 @@ JokerObject* joker_object_new(Joker* joker) joker_object->joker = joker; joker_object->sprite_object = sprite_object_new(); - int tile_index = JOKER_TID + (layer * JOKER_SPRITE_OFFSET); + int tile_index = JOKER_TID + layer * JOKER_SPRITE_OFFSET; int joker_spritesheet_idx = s_joker_get_spritesheet_idx(joker->id); int joker_idx = s_joker_get_sprite_idx_in_sheet(joker->id, joker_spritesheet_idx);