Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.
C calculatorcalculator-gamescasiochesscrossy-roaddrive-madfx-cg50gamesgeometry-dashgraphing-calculatorndlessnumworksnumworks-appsnumworks-calculatornumworks-gamenumworks-gamestetristi-84-plus-ceti-nspire
NumBlocks: rain, snow and thunderstorms
Mason Chenfd7e09f09ff0
diff --git a/games/numblocks/src/data.c b/games/numblocks/src/data.cindex 60066428..5f2a4a62 100644--- a/games/numblocks/src/data.c+++ b/games/numblocks/src/data.c@@ -1179,7 +1179,12 @@ const uint16_t img_pal[5][16] = {{0x0000,0xFFFF,0xC638,0x8C51,0x52AA,0x31A6,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000},};const uint8_t clouds[8192] = {0,0,30,2,0,0,0,0,0,0,0,0,176,5,30,0,0,8,0,0,0,0,128,12,0,112,8,54,0,0,0,0,3,32,30,19,96,0,0,24,28,0,192,0,64,62,14,0,2,12,0,64,96,0,0,0,0,60,0,62,0,0,0,0,6,0,14,48,0,0,0,16,0,0,200,1,64,31,0,0,3,0,0,0,60,0,0,1,0,24,128,127,0,0,128,0,14,0,78,0,0,0,0,0,0,0,60,6,224,31,225,192,7,0,0,128,63,192,128,15,0,0,224,255,0,0,192,0,15,0,254,33,0,0,0,0,0,0,0,4,224,31,246,0,12,0,0,192,7,0,136,9,0,32,224,255,1,0,0,2,15,0,255,1,0,0,0,0,0,0,0,0,224,31,254,17,62,0,0,64,0,0,64,0,128,97,241,255,28,128,24,0,63,128,249,1,0,0,0,0,0,0,0,0,224,55,253,7,62,0,0,0,6,0,224,131,56,0,96,255,1,0,120,0,60,248,240,1,0,0,0,0,0,0,0,0,192,247,248,15,252,1,0,0,11,0,240,1,120,0,4,56,0,0,240,0,220,0,64,0,0,0,0,0,0,8,0,0,192,255,253,15,127,32,0,0,0,0,224,0,8,0,0,40,0,0,224,0,207,129,3,0,0,0,0,0,16,27,0,128,184,255,127,14,63,96,0,0,0,0,98,0,0,0,0,64,0,0,192,0,199,195,3,0,0,0,0,0,128,31,0,192,216,255,63,140,255,8,0,0,0,0,39,0,0,0,0,0,32,0,0,0,240,220,66,0,0,0,0,0,0,12,0,192,248,255,31,152,255,8,0,0,0,0,0,0,0,0,8,0,64,0,0,0,248,200,96,0,0,0,0,0,0,8,0,224,61,255,31,6,255,15,2,0,0,0,0,0,0,0,8,0,0,0,0,0,254,1,240,1,0,0,0,80,0,0,0,0,124,239,15,6,224,7,0,0,0,0,0,0,0,0,8,0,176,3,0,0,90,32,240,1,0,0,0,0,0,0,0,128,62,94,60,134,3,55,0,0,0,0,0,24,0,128,13,0,224,0,0,32,19,64,224,7,0,0,0,0,0,8,0,0,38,126,60,158,7,62,128,0,0,0,0,18,0,128,156,1,96,0,0,48,0,192,112,15,0,0,0,0,0,8,0,0,32,127,2,8,34,55,0,0,0,0,0,0,0,128,182,205,0,0,0,0,0,226,22,14,0,0,0,0,0,0,0,0,0,15,3,72,224,31,0,0,0,0,0,0,0,0,190,248,3,0,0,0,0,98,3,2,156,0,0,0,0,6,0,0,128,125,2,0,128,31,0,0,0,0,0,0,0,0,254,221,3,0,8,0,0,176,133,64,48,0,0,0,0,14,0,0,128,252,67,0,0,12,2,0,0,0,0,0,64,48,254,255,7,0,64,48,0,128,157,192,32,0,0,0,0,164,0,0,0,112,96,0,8,14,2,0,0,0,0,0,0,32,254,255,7,136,0,0,0,4,255,192,70,0,0,0,128,252,0,0,0,120,0,0,80,6,0,0,0,0,0,0,0,0,254,231,31,128,1,0,0,2,50,192,1,0,0,0,0,28,0,2,0,26,0,0,126,0,0,0,0,0,0,0,0,192,255,135,15,0,0,0,0,242,48,128,17,0,0,0,0,0,132,7,0,30,64,1,190,1,0,0,0,0,0,0,0,248,167,7,14,0,0,0,0,130,120,7,18,0,0,0,192,48,8,0,0,4,0,0,240,0,0,0,0,0,0,0,0,248,245,15,142,0,0,0,0,128,255,255,15,0,0,0,224,63,27,0,0,0,0,0,224,0,0,0,0,32,0,0,0,249,184,4,155,1,48,4,128,128,249,221,63,0,0,0,240,15,31,0,0,0,0,0,128,0,0,0,8,32,0,0,128,124,7,0,224,41,0,0,240,225,225,236,25,0,0,0,190,14,14,0,0,0,0,32,152,0,0,192,0,96,0,0,128,252,15,0,224,15,0,0,224,243,241,241,29,0,0,0,218,4,7,128,0,0,0,0,222,33,0,0,0,96,2,0,0,252,15,0,224,29,6,0,192,243,241,19,12,0,0,0,152,173,3,0,12,0,49,0,255,61,0,0,0,224,3,0,0,248,7,0,224,241,23,0,120,159,0,0,32,0,0,0,28,160,7,12,0,32,38,128,253,63,0,0,0,0,0,32,0,224,7,0,232,1,7,0,106,31,14,0,32,0,0,128,61,0,14,12,0,48,14,192,224,30,0,0,0,20,0,48,0,224,7,0,222,3,28,0,96,15,14,0,32,0,0,0,56,2,14,12,4,0,0,0,32,28,0,8,0,0,0,62,0,96,0,0,14,0,24,0,224,111,63,0,0,0,0,0,224,3,26,31,0,0,0,12,0,0,0,28,0,0,0,124,0,112,0,0,0,176,143,3,224,15,63,0,0,0,0,0,250,3,48,15,2,0,128,32,0,0,0,24,0,8,0,252,3,112,0,0,0,0,254,1,128,3,15,0,0,128,0,0,255,3,224,7,0,6,192,0,0,32,0,24,128,12,0,252,102,32,0,0,12,0,248,3,128,255,1,0,4,0,0,0,240,3,128,12,0,128,0,0,0,224,0,28,128,8,0,247,34,0,0,0,12,136,253,3,240,252,0,0,6,24,4,0,224,1,0,28,16,128,0,0,32,225,225,127,128,0,0,31,160,1,0,0,0,252,204,224,224,255,64,0,0,56,0,8,0,0,128,24,28,216,23,0,96,123,240,63,0,0,0,14,120,0,0,2,6,252,193,255,240,243,249,0,0,96,0,8,4,64,224,73,28,252,63,0,96,24,240,30,0,0,0,0,56,0,64,6,6,255,251,239,240,247,255,9,0,64,0,12,130,0,224,217,15,48,0,32,2,8,32,28,0,0,0,8,12,0,0,0,0,246,9,97,112,255,231,31,1,249,0,28,224,6,224,251,7,0,128,3,0,0,0,142,0,2,64,14,2,0,0,0,0,194,8,248,127,255,255,31,0,144,8,222,96,3,248,255,7,0,0,66,0,0,0,192,1,0,136,0,2,0,0,8,0,2,152,248,111,255,255,127,0,0,129,121,224,129,255,254,7,0,64,224,7,7,0,240,1,0,8,128,2,0,0,8,0,26,0,232,48,246,215,63,0,0,128,121,96,1,242,115,63,0,96,226,0,14,0,252,0,0,0,128,96,0,0,2,0,30,0,240,48,240,199,63,3,0,206,224,243,1,192,131,127,0,96,2,0,56,6,255,0,130,0,0,241,1,240,0,0,12,0,96,56,216,3,113,0,0,207,249,243,1,192,129,126,0,112,2,32,188,6,124,0,128,0,32,80,2,240,1,0,188,0,32,0,240,129,113,0,0,195,185,231,1,128,0,56,0,48,128,48,0,6,62,0,0,0,96,12,6,224,1,0,56,0,236,224,224,224,253,0,0,0,240,96,0,112,131,8,0,224,128,0,32,2,30,2,0,0,0,8,4,240,0,0,0,0,12,120,4,240,127,0,80,0,96,0,0,120,128,0,0,224,1,0,240,3,30,0,0,0,0,29,8,248,24,0,0,0,24,104,131,240,112,0,0,2,48,0,0,120,0,0,0,32,0,0,32,0,12,0,0,0,128,12,156,216,43,0,0,0,62,4,128,65,204,64,0,2,32,0,0,0,0,0,0,0,0,0,0,128,13,0,0,0,240,24,252,248,15,0,0,0,4,32,0,128,220,128,8,0,0,0,0,192,0,0,0,0,0,0,192,243,8,0,0,0,32,12,34,248,15,0,0,2,0,0,0,128,159,129,0,0,65,0,192,208,1,0,0,0,3,1,224,255,60,0,0,0,0,12,35,40,0,0,0,0,0,0,0,0,156,0,0,0,1,2,32,192,0,0,0,0,2,222,193,255,11,0,0,0,0,156,35,160,1,0,0,0,0,0,0,0,0,0,0,64,16,24,48,0,0,0,0,0,64,254,199,255,3,0,0,0,0,24,0,128,3,0,0,0,0,8,0,38,6,0,32,0,2,12,0,8,0,0,0,0,0,254,227,255,99,0,0,0,4,12,0,96,0,0,0,0,0,156,0,255,7,0,32,0,3,28,128,28,0,0,4,0,0,59,248,255,241,0,0,0,62,14,64,32,0,0,0,0,0,140,0,255,7,0,0,0,2,56,0,16,0,0,0,0,0,126,127,242,248,3,0,0,60,14,0,32,0,2,0,0,0,0,4,63,16,0,64,0,0,192,143,192,0,128,0,0,0,254,31,246,248,0,0,0,28,8,192,3,0,0,0,0,224,0,0,127,9,0,0,0,0,0,136,0,0,192,0,0,0,222,31,198,0,0,0,0,14,4,0,0,0,0,0,128,192,4,128,15,207,0,0,120,0,0,192,0,0,224,0,0,0,154,15,135,129,0,0,32,15,1,0,240,7,0,0,128,128,0,128,1,216,1,0,60,0,0,0,0,0,32,32,0,2,134,15,135,19,0,0,0,0,1,0,200,5,0,0,128,128,1,128,1,142,1,64,126,0,0,0,0,0,32,0,0,0,6,143,131,127,0,0,0,0,0,0,77,6,32,0,64,132,0,0,0,31,0,0,60,0,0,0,0,0,48,4,0,0,4,252,4,31,0,0,0,0,32,192,28,15,0,0,96,2,0,0,80,31,0,16,48,125,0,0,0,0,176,15,0,0,4,248,132,7,0,0,0,0,96,192,127,31,0,0,64,15,0,0,192,63,0,0,240,61,0,0,0,0,242,3,0,0,0,248,160,39,0,0,0,2,0,192,255,127,0,0,96,63,192,1,32,15,0,0,224,63,0,0,0,0,102,0,0,0,0,248,224,127,0,0,96,0,0,128,191,127,0,0,252,15,0,0,96,15,0,0,240,121,0,0,0,0,54,8,0,0,0,240,195,255,0,0,0,0,0,0,255,127,0,0,0,143,0,0,224,15,0,6,112,224,1,0,0,0,7,126,0,32,0,240,131,227,0,0,0,0,0,12,254,127,0,48,1,8,0,128,0,32,0,0,112,52,0,0,0,4,38,124,0,0,0,16,2,94,0,0,0,0,0,12,254,255,67,32,0,12,0,128,0,0,0,128,56,31,0,0,0,4,176,25,0,0,0,24,2,31,0,0,0,0,48,128,255,255,219,0,0,60,128,8,0,64,0,0,8,31,0,0,0,12,28,141,0,0,0,0,130,63,0,0,0,0,0,142,255,247,195,0,0,60,198,47,236,192,0,0,192,79,2,0,0,8,207,0,0,0,0,0,194,60,1,0,0,0,0,30,242,254,113,0,0,30,227,167,61,224,0,128,131,15,0,0,0,0,158,9,0,0,0,0,128,31,128,3,0,0,0,2,222,254,13,0,0,31,3,62,35,128,0,128,7,28,0,0,0,192,208,15,4,0,0,0,0,31,0,0,0,0,0,0,134,255,15,0,0,223,221,15,2,128,0,128,132,156,0,0,0,128,128,15,0,0,0,0,0,12,0,0,0,0,0,8,2,248,63,0,0,14,252,14,6,64,0,0,28,200,32,0,0,192,0,14,0,0,0,0,12,24,0,0,0,0,0,48,0,240,63,0,0,18,126,14,0,0,0,0,24,222,3,0,0,112,0,24,0,0,0,0,30,8,2,0,0,0,0,0,0,250,210,0,0,0,63,6,0,8,0,0,128,127,2,0,0,56,0,48,0,16,0,0,0,12,4,0,0,0,0,0,0,62,224,1,6,64,0,2,0,0,0,128,0,127,0,0,0,120,0,32,0,0,0,0,6,30,0,0,0,0,0,0,0,116,216,0,4,192,0,0,64,0,0,0,120,255,0,0,50,224,0,0,0,0,0,0,6,159,0,32,128,0,0,0,6,184,195,0,0,248,0,0,2,56,0,0,97,255,0,0,2,248,1,0,0,0,0,0,131,31,0,2,128,0,0,0,222,220,240,1,128,216,0,0,4,62,0,192,97,239,1,0,6,188,1,32,0,0,96,3,15,64,0,2,128,0,0,64,156,239,112,196,1,0,32,0,0,0,0,0,112,255,1,0,14,124,9,0,6,0,0,0,248,0,0,0,0,0,0,64,13,130,96,224,32,32,64,0,0,0,0,0,224,127,0,0,158,159,49,0,7,0,0,0,108,0,0,0,0,0,0,128,1,0,120,48,32,32,0,2,0,0,2,0,200,127,0,0,128,143,113,0,0,0,2,136,60,0,0,0,2,0,0,192,3,0,0,0,48,0,0,0,0,96,0,0,254,127,0,0,0,128,102,0,0,0,0,128,24,0,0,0,6,0,0,128,225,128,0,4,54,0,0,0,0,224,0,0,254,255,0,6,0,0,32,0,0,0,8,128,152,0,0,0,2,0,8,0,0,0,0,14,0,64,0,0,0,247,0,0,254,255,0,14,0,0,0,0,0,0,0,0,128,0,128,0,24,0,56,0,0,0,24,24,0,248,0,0,128,7,0,0,255,127,1,12,0,0,0,0,128,2,0,0,0,0,128,0,8,0,0,0,16,0,216,33,0,248,0,0,136,7,0,0,255,255,3,12,0,0,0,0,192,1,0,0,0,0,0,0,0,0,0,8,208,0,200,1,0,224,0,0,136,31,0,0,246,255,131,6,0,0,0,0,128,128,0,0,32,11,0,0,0,0,0,0,0,0,136,0,0,224,0,0,152,125,0,0,2,236,194,7,0,0,12,0,48,8,0,0,240,63,24,32,0,0,0,0,0,0,193,0,0,60,0,0,152,60,0,0,0,120,16,14,0,0,30,0,112,66,3,0,224,63,0,64,3,0,32,0,0,0,1,0,128,0,0,0,204,28,0,0,198,121,1,8,0,128,73,0,108,1,3,0,128,96,0,0,7,0,0,0,96,0,48,8,0,1,146,0,252,157,0,0,226,32,0,8,0,0,240,0,120,1,0,0,224,8,0,32,32,0,18,0,32,0,96,0,0,0,231,128,223,201,0,0,242,0,0,6,0,0,176,96,48,6,0,16,224,11,48,224,56,2,126,0,0,0,224,0,4,16,127,0,223,207,1,0,242,0,0,0,0,0,224,0,248,3,0,32,98,2,96,8,120,3,248,3,0,0,96,0,0,240,62,129,31,135,1,0,194,15,0,0,0,0,224,1,252,7,0,0,0,64,224,15,124,31,192,3,64,0,98,4,0,240,198,247,127,226,0,0,192,7,0,0,0,8,248,0,152,7,0,0,8,0,104,12,32,198,249,3,0,0,32,66,0,32,199,255,63,128,0,0,240,2,0,0,32,72,60,64,12,4,0,0,8,184,121,28,48,194,255,6,0,0,0,1,0,0,128,255,255,0,0,0,64,2,0,0,0,136,63,0,32,12,0,0,0,240,15,252,240,195,255,0,0,0,0,143,0,0,17,255,255,7,1,0,64,48,0,0,0,0,123,6,48,17,48,0,128,224,31,252,56,199,131,0,0,0,6,4,0,0,0,127,255,5,0,96,130,0,0,0,0,0,120,0,54,128,0,0,128,0,183,222,251,223,99,0,0,8,2,0,0,0,0,239,191,0,0,240,3,1,0,0,0,0,96,0,120,128,1,12,0,0,143,199,251,127,224,0,0,4,0,0,0,0,0,255,253,10,0,224,3,0,0,0,0,0,248,7,124,192,247,1,0,128,63,224,255,127,128,0,0,128,24,0,0,0,7,103,240,9,0,224,15,24,2,28,0,0,252,7,124,227,255,8,0,192,60,224,252,31,3,0,0,128,16,0,0,0,13,246,243,9,0,200,15,0,0,0,0,0,240,9,120,99,195,8,0,192,29,64,248,223,7,0,0,224,0,0,0,0,25,243,247,7,24,195,121,0,0,0,0,0,118,72,0,102,0,64,0,128,15,128,131,255,39,0,0,240,0,0,0,0,31,246,251,7,0,255,60,0,0,0,0,0,246,1,224,127,0,127,0,0,0,128,128,255,3,0,0,192,0,0,0,0,31,254,159,63,0,255,13,192,0,0,0,0,252,1,224,119,64,24,17,64,112,0,192,159,1,112,0,0,0,0,0,0,254,255,9,201,48,64,28,8,0,0,0,0,254,193,255,51,134,13,0,0,96,0,0,159,128,96,0,0,0,0,48,0,255,255,0,136,57,0,248,155,192,4,0,0,255,192,63,0,159,13,0,0,97,192,243,255,112,36,0,0,0,0,48,4,252,223,8,200,127,8,216,15,64,24,0,0,222,225,127,224,221,0,0,0,0,0,247,63,32,112,0,0,0,0,48,0,236,127,0,252,255,28,252,7,224,24,0,128,255,193,251,224,56,0,0,0,192,1,254,31,0,113,0,0,0,0,2,0,252,55,0,246,127,142,253,7,96,0,0,224,63,200,221,248,109,11,0,0,0,32,220,15,128,105,0,0,0,0,128,136,252,7,0,231,51,200,127,62,0,0,0,240,62,216,255,249,227,47,0,0,0,0,15,3,192,229,3,0,0,0,192,220,248,3,0,119,243,223,255,63,0,0,0,56,62,192,255,121,35,50,0,0,0,0,32,0,128,224,0,0,0,0,96,192,248,0,128,112,239,29,255,63,188,1,6,56,100,199,255,48,0,120,0,0,0,0,112,0,0,0,0,0,0,0,96,128,251,0,128,96,137,156,191,127,143,0,0,0,124,255,255,36,192,112,0,0,0,0,96,0,128,0,0,0,0,0,128,192,235,0,0,96,24,8,39,231,15,12,0,0,254,255,252,44,192,225,32,0,0,0,32,0,128,1,0,0,67,128,0,0,9,0,0,0,12,0,140,199,159,19,0,2,208,255,125,28,0,128,3,0,0,0,32,0,128,8,0,48,0,0,0,8,4,0,0,0,0,64,236,247,31,3,32,2,176,255,127,0,0,2,1,0,0,0,0,0,226,0,0,112,0,0,0,28,35,0,0,0,2,0,128,242,31,0,32,0,224,255,255,15,0,38,0,0,0,0,0,0,32,128,0,8,105,0,0,12,115,0,16,0,4,192,128,13,15,0,0,0,224,247,255,15,2,68,0,0,0,60,0,0,0,0,0,1,248,0,0,14,99,0,16,0,0,0,128,60,2,0,0,32,224,199,255,3,14,8,0,0,0,120,0,0,8,0,8,0,248,1,8,62,3,0,96,224,0,0,140,28,96,0,0,32,48,0,56,4,15,0,0,0,4,240,0,0,200,33,63,0,0,4,4,124,0,0,48,0,0,0,8,0,64,0,0,0,208,2,32,0,0,0,0,0,140,240,0,0,200,112,6,0,12,4,0,54,0,0,0,7,0,0,1,0,58,0,0,192,224,18,0,0,0,0,4,7,204,4,0,0,192,127,6,0,14,15,0,7,0,32,160,7,0,128,0,0,96,0,8,192,127,0,0,0,0,0,128,7,254,3,0,0,130,115,12,0,48,124,129,12,0,6,176,1,3,0,0,0,224,0,0,64,60,0,0,0,0,0,128,7,254,251,0,0,15,243,60,0,64,255,65,24,0,4,156,7,0,128,0,0,192,0,0,128,60,0,0,0,2,0,0,60,254,31,0,0,132,243,239,0,0,246,97,2,0,16,243,7,8,0,0,0,0,0,2,0,196,0,0,192,7,0,64,120,190,63,192,64,192,254,192,5,0,248,192,3,0,0,50,0,0,0,0,0,0,0,0,32,0,0,0,128,3,0,0,62,248,31,0,0,156,252,143,0,0,255,253,35,0,32,66,0,0,0,0,0,0,0,0,0,129,0,0,192,0,0,0,62,224,59,0,16,159,253,12,4,32,254,255,56,0,32,210,0,0,0,0,0,0,0,0,0,192,0,0,128,0,0,0,220,231,127,0,64,142,29,12,8,160,255,127,32,0,32,255,7,0,0,0,6,0,16,0,0,0,0,224,0,192,0,0,248,119,254,1,192,128,56,0,203,191,31,7,192,0,0,242,1,0,0,0,2,7,0,128,0,0,0,0,0,192,1,0,240,7,248,131,248,0,39,1,194,255,199,3,0,0,192,225,0,0,0,0,2,7,0,0,0,0,0,0,0,192,1,2,240,71,201,129,248,0,198,1,194,207,192,3,0,0,0,96,0,0,0,0,14,4,0,0,0,0,0,0,0,192,1,2,224,127,223,9,96,0,130,0,98,151,244,1,0,12,0,96,0,0,0,24,14,24,0,0,0,0,0,0,0,128,1,0,224,252,255,0,192,1,0,0,160,25,62,25,4,29,128,1,0,0,0,120,2,14,8,0,0,0,0,0,0,0,32,0,48,246,255,0,8,0,128,0,160,8,254,0,0,124,192,0,0,0,0,236,64,0,8,0,0,0,0,0,0,0,0,0,8,243,63,17,192,0,192,0,16,124,255,128,0,32,0,32,34,0,0,248,1,0,12,0,0,8,0,0,0,0,0,0,0,194,63,2,192,0,128,0,0,126,127,224,0,0,32,112,123,0,0,216,1,0,0,0,0,30,14,12,0,36,0,0,0,6,126,0,224,0,67,0,128,255,7,96,0,0,32,120,126,6,0,216,1,0,0,0,0,63,12,28,0,0,0,0,0,0,119,64,115,128,7,0,0,252,143,32,0,0,0,102,252,7,0,254,1,0,0,0,192,27,152,13,0,0,0,0,0,224,55,224,32,0,60,0,0,252,159,1,65,0,0,160,253,15,0,255,1,0,0,0,0,80,3,55,0,0,0,0,0,224,127,226,0,0,14,0,0,252,223,29,64,0,0,0,15,7,160,251,16,0,0,0,0,96,3,126,0,0,0,0,0,240,127,224,1,112,7,0,0,54,254,63,65,0,0,0,63,6,160,253,127,0,0,0,0,96,3,24,0,0,16,0,0,224,127,72,1,32,0,7,0,48,255,29,0,0,128,64,30,6,0,248,127,0,0,0,0,96,96,0,0,0,112,0,0,192,255,223,3,0,0,7,0,224,255,65,0,0,192,0,30,2,0,112,8,0,0,0,12,104,224,192,0,0,32,0,0,128,255,159,7,0,0,0,0,0,253,9,0,0,96,64,8,2,0,96,0,0,0,0,255,124,128,208,0,0,1,0,0,16,255,127,16,48,6,0,0,0,216,31,4,0,32,0,0,0,0,0,0,0,0,0,255,13,192,0,0,0,0,0,0,0,255,55,96,32,2,0,0,2,200,247,0,27,32,2,7,0,0,0,12,0,0,0,190,15,240,1,64,0,96,0,0,6,244,7,227,1,0,0,192,0,12,254,0,0,32,34,6,0,0,4,0,0,0,0,62,0,0,192,0,0,0,0,0,30,246,95,240,1,0,0,192,0,30,7,0,0,70,99,120,0,0,0,0,0,0,0,79,0,0,240,1,0,0,0,0,14,255,123,236,3,0,0,96,0,15,3,8,3,252,39,60,0,0,16,0,0,0,0,24,0,0,112,0,0,0,0,0,158,247,47,248,3,0,0,48,128,133,39,8,3,252,15,12,0,0,147,1,6,0,0,56,0,0,96,0,1,0,0,0,31,255,3,120,4,0,0,32,0,241,127,8,0,176,204,29,0,0,192,7,2,32,0,56,0,64,8,0,0,0,0,0,28,31,0,28,0,0,0,32,0,48,142,0,0,0,206,24,0,0,224,14,0,48,2,60,1,64,24,64,0,6,0,0,128,11,0,31,0,0,0,0,128,48,4,0,0,128,207,31,0,0,224,15,8,34,0,53,0,0,128,1,8,38,0,0,240,31,0,31,0,8,0,0,128,45,132,1,0,224,143,63,0,2,240,199,3,0,0,57,0,16,2,96,124,6,0,0,224,30,0,6,0,0,0,0,192,143,253,3,0,224,221,63,0,0,240,15,0,0,14,60,0,0,6,224,16,0,0,0,0,0,0,0,0,0,0,0,96,13,220,1,0,32,252,120,0,0,248,31,0,0,14,4,1,128,30,0,1,1,0,0,0,192,3,0,192,0,0,0,48,12,236,0,0,32,255,15,0,0,248,15,0,0,12,0,0,150,7,96,61,2,0,0,0,136,3,0,192,0,0,0,56,8,241,1,0,128,163,15,192,17,225,3,0,0,16,96,0,131,1,98,30,0,0,32,1,12,12,64,16,0,0,64,12,128,243,1,0,0,32,253,0,0,224,3,0,0,2,96,0,12,32,247,31,0,0,32,0,6,0,8,0,0,0,0,180,128,113,0,1,28,0,252,1,96,224,71,0,0,128,7,0,60,240,127,0,0,0,32,48,32,0,28,64,0,64,0,55,14,124,1,248,1,0,126,0,32,0,32,0,0,128,117,0,52,128,124,0,0,0,32,60,6,0,254,3,0,0,0,56,8,120,0,192,3,128,31,0,0,0,0,0,0,32,120,1,15,223,39,0,0,0,0,15,30,0,255,15,0,0,0,120,0,120,192,218,0,0,14,0,0,0,0,0,0,32,0,32,159,242,39,0,0,0,0,7,12,0,210,15,0,0,0,0,0,252,3,130,0,0,0,0,0,0,0,0,0,0,0,96,50,56,51,0,32,0,0,30,207,17,16,0,1,0,110,0,128,207,3,0,0,0,0,0,0,0,0,0,0,0,0,254,167,125,56,0,0,0,0,8,141,135,0,3,0,0,0,8,128,221,135,0,48,128,7,0,0,0,28,0,192,128,0,255,191,255,244,0,8,0,0,0,16,134,3,15,0,0,0,72,0,129,140,0,32,0,0,0,0,0,12,0,64,156,0,254,15,192,48,0,56,0,0,0,32,222,2,0,0,0,0,136,32,140,221,0,96,4,0,0,0,0,158,0,0,60,0,252,1,128,129,3,112,0,0,128,15,248,28,0,0,6,0,128,248,204,255,0,120,0,0,0,0,0,220,1,128,30,0,255,1,224,224,39,112,128,0,0,0,32,24,0,0,32,0,0,144,8,255,0,240,16,0,0,0,0,252,64,132,6,240,255,15,0,240,15,96,199,0,0,0,0,0,0,0,0,0,0,0,0,255,0,224,7,0,0,0,0,252,192,255,7,128,255,1,0,96,15,240,7,0,0,0,32,0,0,0,0,0,32,0,128,247,0,192,15,0,0,0,0,175,176,255,7,0,241,0,0,64,6,240,3,0,0,15,240,96,0,0,0,0,96,130,152,63,0,192,15,0,0,0,0,127,224,255,55,0,8,3,0,0,35,240,15,0,36,8,176,0,3,0,0,0,48,130,252,127,192,3,8,0,0,0,0,226,192,254,63,0,12,8,0,0,112,240,7,0,12,24,0,0,0,0,0,0,112,128,252,56,0,0,12,0,0,0,0,8,128,252,3,0,12,0,0,0,240,242,3,0,8,32,159,0,32,248,0,0,0,130,124,31,0,120,4,0,112,0,0,8,160,220,128,4,12,0,0,0,240,255,1,3,24,0,31,0,0,252,1,0,0,128,239,3,128,24,0,0,240,0,0,136,0,216,128,0,0,0,0,0,248,11,32,0,8,122,59,0,128,248,0,0,129,129,127,0,192,9,96,0,242,1,0,0,4,240,193,3,0,0,0,0,240,25,0,0,24,254,99,0,192,225,0,128,193,192,63,0,192,31,0,0,14,0,0,0,8,224,201,2,0,0,0,0,224,57,8,2,0,247,51,0,200,113,0,8,128,0,159,0,208,31,0,0,15,0,0,0,8,192,193,3,16,0,0,0,224,239,207,3,0,227,63,0,224,49,0,0,0,28,192,1,192,23,0,0,13,32,0,0,44,124,98,0,0,0,0,0,96,63,192,9,0,160,32,0,246,55,0,0,0,128,15,0,192,226,1,192,28,4,0,0,8,56,6,6,96,0,0,0,4,24,96,28,0,176,48,0,49,62,0,0,0,0,12,12,128,247,0,128,8,0,0,0,8,152,2,6,0,0,0,0,118,8,96,96,128,0,0,0,0,38,0,0,0,134,28,8,144,255,69,0,8,15,0,0,0,4,3,31,16,0,0,0,254,15,96,224,128,64,0,0,0,34,0,0,0,142,28,0,210,255,243,0,8,2,0,0,0,0,3,31,146,0,0,32,248,1,0,194,129,96,0,0,8,0,0,128,0,2,48,0,192,253,247,145,8,0,0,0,0,144,7,248,14,0,0,0,248,192,0,181,0,32,0,0,56,0,0,240,1,0,240,0,194,255,255,134,0,0,0,2,0,128,13,34,6,2,0,0,240,193,128,240,1,0,0,0,32,0,0,8,0,0,160,0,240,255,63,14,4,0,0,6,0,192,188,1,0,4,0,0,251,202,0,184,1,0,0,0,0,7,0,24,0,0,0,0,64,251,127,28,0,32,0,0,0,152,220,0,0,0,0,2,255,131,3,56,0,0,0,0,0,3,0,0,128,0,2,0,224,239,127,152,0,56,0,0,0,20,65,224,0,16,0,0,220,193,3,96,0,0,0,0,4,0,0,0,225,0,2,0,244,255,191,4,0,62,0,0,0,0,124,224,0,0,0,0,156,8,0,8,0,2,0,0,8,0,0,128,32,0,0,0,238,246,143,7,0,31,0,0,0,0,126,176,0,0,0,0,31,0,0,0,136,1,0,0,24,0,0,0,48,0,0,0,253,99,158,7,128,159,0,0,0,0,127,179,0,0,0,0,30,0,0,0,0,128,0,0,8,0,0,0,118,8,24,0,253,224,127,12,132,79,0,0,0,96,255,47,0,0,0,0,124,0,0,6,0,198,1,0,0,0,0,16,255,99,22,0,128,224,63,12,12,31,0,0,0,32,222,57,0,0,0,0,240,0,0,0,0,0,0,0,0,0,0,0,222,99,0,0,128,224,127,12,3,156,3,0,64,0,222,113,0,1,0,16,128,15,0,0,48,0,0,0,0,0,0,0,143,63,0,0,128,200,127,25,0,220,1,0,16,0,156,0,0,0,0,6,192,15,3,0,176,0,0,0,0,0,0,60,0,0,3,0,192,217,247,71,14,248,1,0,24,0,1,0,0,0,0,0,128,1,3,6,56,0,0,0,0,0,0,62,0,0,3,0,226,205,115,32,2,2,0,0,12,0,0,64,0,0,0,0,200,96,0,128,28,0,0,0,0,0,0,6,32,4,0,0,255,141,127,0,192,7,64,0,199,0,0,64,0,0,0,128,120,56,0,208,12,0,0,0,0,192,12,8,64,0,0,0,255,197,125,32,0,1,0,28,7,0,0,0,0,2,0,128,56,0,0,24,30,0,0,0,0,192,15,56,0,0,0,0,251,3,61,64,4,0,0,127,31,0,0,0,0,224,0,0,0,0,4,4,222,0,0,0,0,192,31,48,0,64,8,128,255,98,253,128,0,0,128,61,127,0,0,0,0,0,0,0,0,28,0,0,2,0,0,0,0,96,15,32,0,0,32,130,252,113,126,128,0,0,240,30,255,3,0,8,0,6,8,4,0,62,197,1,2,0,0,0,0,112,132,1,0,224,99,2,192,97,126,128,0,8,96,31,252,1,0,0,0,66,8,0,0,255,221,1,0,2,0,0,128,55,140,129,32,128,135,3,153,224,126,0,0,8,32,251,32,0,0,128,4,113,8,0,0,255,201,0,3,2,0,0,128,47,8,196,0,0,7,129,221,0,118,96,0,0,32,200,0,0,0,0,0,114,8,0,0,254,217,0,0,0,0,0,0,24,14,62,0,8,12,0,126,0,192,99,0,8,0,198,0,0,0,0,96,246,81,0,0,252,208,0,2,0,0,0,0,28,15,24,130,9,56,0,127,0,200,33,0,0,0,0,0,0,0,0,0,254,7,0,0,252,1,0,128,0,0,0,0,2,7,126,128,8,0,0,99,7,152,1,0,4,0,0,0,0,0,0,64,156,15,0,0,232,7,4,128,1,2,0,0,0,51,126,216,200,0,0,2,0,248,33,0,0,0,0,0,0,0,0,192,159,13,0,0,192,48,2,128,0,0,0,0,12,96,36,204,11,0,0,2,0,255,1,0,0,240,0,0,0,0,128,240,155,7,64,0,0,56,2,12,0,0,0,0,28,129,1,4,3,0,0,0,0,255,0,18,0,248,39,0,0,0,128,193,207,39,64,0,0,24,2,0,0,0,0,0,24,0,3,84,2,128,128,0,0,30,3,63,0,64,127,0,0,0,0,192,231,63,129,1,128,15,0,16,0,0,0,0,0,0,0,122,0,0,151,0,0,192,3,0,0,0,2,0,0,0,0,192,225,28,128,0,0,136,0,0,0,0,32,0,8,0,0,0,32,32,128,0,0,128,16,0,0,0,0,0,0,0,0,128,1,24,0,0,0,24,64,12,1,0,0,7,4,0,0,4,112,102,192,0,0,128,19,0,0,0,128,1,0,0,0,8,0,124,0,0,0,0,0,0,0,96,0,12,3,0,0,0,48,6,192,0,0,128,1,0,0,0,192,1,0,0,0,24,236,127,0,0,32,3,0,1,0,192,64,12,1,0,128,0,12,1,192,0,0,194,0,0,0,0,32,8,0,0,0,0,248,255,0,0,96,0,0,4,0,64,8,0,0,0,0,0,2,12,226,192,0,196,0,0,0,0,32,0,126,0,0,0,252,255,0,8,0,16,0,12,0,64,24,0,0,0,0,0,0,28,114,128,0,220,32,0,32,128,32,32,134,2,0,128,255,247,0,8,0,0,0,14,0,0,62,0,0,0,0,0,0,24,96,6,0,252,9,2,0,128,32,0,70,0,0,224,255,127,0,0,0,0,2,0,0,0,6,2,24,0,0,0,132,0,0,0,0,252,91,2,0,0,0,0,0,0,0,224,253,25,0,0,0,0,2,0,0,0,28,2,118,0,0,0,128,0,0,0,192,252,255,0,0,0,0,0,0,0,0,224,244,1,0,0,0,0,26,0,0,0,28,227,255,1,0,0,224,1,0,0,0,255,243,0,2,0,0,0,0,8,0,192,255,0,0,0,0,0,12,8,0,0,216,227,255,1,96,0,242,3,0,0,0,255,227,7,23,6,0,0,0,0,16,0,191,1,0,0,0,0,4,120,0,0,240,99,159,0,224,1,242,1,0,0,0,242,247,3,18,6,8,0,0,0,4,0,31,0,0,0,0,0,6,128,0,0,210,33,255,129,0,0,96,0,0,64,0,224,255,0,96,6,0,0,0,0,12,0,30,0,0,0,0,0,7,0,0,0,194,3,254,1,0,0,0,0,0,2,0,248,255,5,48,7,0,0,8,0,8,0,54,0,0,0,0,0,0,128,0,0,198,3,126,0,0,0,0,0,32,0,3,252,239,1,60,7,0,0,24,0,28,0,2,0,0,0,0,64,0,128,0,0,31,7,254,0,0,0,0,2,48,0,0,248,61,0,8,0,36,0,0,0,10,0,128,0,0,0,0,0,0,0,0,0,31,134,240,0,0,0,0,2,192,0,4,96,28,0,0,0,230,6,132,65,3,0,0,0,0,14,0,8,34,0,0,32,30,15,192,16,0,0,0,6,192,0,0,32,31,0,0,32,231,3,0,0,7,2,0,0,0,8,0,8,0,0,0,160,31,0,0,0,0,128,0,0,0,0,0,158,31,0,0,0,7,3,0,0,4,3,0,0,0,0,0,8,1,0,128,128,14,0,88,0,0,0,0,0,0,32,0,0,31,0,128,0,6,38,0,0,60,0,0,0,0,12,0,8,0,0,128,160,31,0,220,0,0,128,0,32,32,56,0,0,14,4,128,28,7,126,0,0,60,0,0,0,0,4,0,0,224,0,24,190,31,1,254,3,2,2,4,56,248,24,0,0,6,2,128,30,0,62,0,0,56,0,2,0,0,0,0,0,0,0,28,230,63,0,126,0,128,0,8,176,244,64,4,0,0,114,0,220,0,28,0,0,120,3,3,0,0,0,0,0,0,0,24,252,95,0,120,225,128,0,0,176,14,0,0,0,14,0,0,156,0,14,0,0,0,0,0,0,0,0,0,0,0,32,156,223,93,0,120,128,0,32,2,12,136,16,0,0,15,0,0,12,4,31,0,0,0,0,12,0,0,0,0,0,14,225,159,143,3,192,12,128,113,96,0,6,0,32,0,0,36,34,8,188,0,28,0,0,2,0,0,0,8,32,0,0,248,255,159,159,159,216,128,128,0,96,0,7,0,0,0,64,140,7,12,120,4,64,0,3,3,0,0,4,136,32,0,0,96,159,207,207,63,140,113,0,0,96,0,7,0,0,0,200,29,0,128,8,2,0,0,2,0,0,136,0,0,0,0,0,32,15,30,191,63,136,96,0,0,32,128,2,224,0,0,192,63,0,128,0,0,11,0,0,0,1,140,1,3,0,0,0,0,0,30,255,255,200,32,25,0,0,67,48,192,0,0,194,31,0,0,2,0,0,0,240,128,1,128,0,3,0,0,0,0,0,54,252,63,136,97,28,32,32,3,24,24,16,0,195,3,0,0,2,196,0,0,240,16,1,128,192,0,0,48,0,0,1,103,156,39,140,1,12,12,96,0,0,28};+const uint8_t rain_run[93][4] = {{0,3,15,221},{0,22,3,74},{0,30,3,74},{0,44,5,120},{1,27,4,98},{3,47,3,64},{8,0,4,98},{9,43,7,114},{10,63,7,114},{11,2,1,45},{13,2,1,44},{15,2,1,45},{19,10,2,94},{22,10,1,134},{23,35,1,29},{25,10,16,203},{25,35,1,29},{27,40,1,30},{33,40,1,47},{39,55,6,97},{40,40,1,31},{45,41,4,64},{65,59,10,162},{65,60,2,48},{69,60,1,47},{78,59,1,84},{81,63,2,32},{82,19,3,93},{85,12,8,130},{86,19,1,95},{89,19,2,92},{91,27,3,64},{92,5,4,75},{93,44,10,155},{95,27,1,62},{99,60,1,29},{101,5,1,121},{101,60,1,29},{102,0,1,50},{102,26,2,34},{103,5,1,104},{105,5,3,150},{106,6,15,188},{109,5,1,164},{109,56,3,102},{111,5,5,130},{111,29,2,32},{113,38,5,81},{115,56,5,113},{119,17,7,114},{120,1,5,97},{121,54,5,97},{122,0,2,65},{122,42,6,97},{126,1,1,95},{127,54,1,95},{128,57,4,90},{129,25,3,48},{134,57,1,97},{137,57,1,69},{142,18,8,138},{149,25,1,84},{151,25,4,80},{153,18,1,84},{155,42,9,143},{160,43,5,81},{167,54,5,81},{168,17,11,164},{184,24,15,188},{185,43,4,81},{191,43,1,80},{191,63,2,32},{197,58,5,81},{199,50,11,164},{201,20,4,64},{211,0,4,98},{217,30,2,32},{218,21,1,117},{220,21,11,173},{223,8,5,81},{227,0,4,98},{232,14,3,134},{233,24,11,164},{235,61,10,167},{236,14,8,162},{236,45,3,48},{237,13,2,32},{240,3,3,48},{241,48,3,48},{248,61,2,103},{252,43,4,99},{253,48,1,34},{255,48,1,44}};+const uint8_t rain_idx[257] = {0,4,5,5,6,6,6,6,6,7,8,9,10,10,11,11,12,12,12,12,13,13,13,14,15,15,17,17,18,18,18,18,18,18,19,19,19,19,19,19,20,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,24,24,24,24,25,25,25,25,25,25,25,25,25,26,26,26,27,28,28,28,29,30,30,30,31,31,32,33,34,34,35,35,35,35,36,36,38,40,41,41,42,43,43,43,45,45,47,47,48,48,49,49,49,49,50,51,52,54,54,54,54,55,56,57,58,58,58,58,58,59,59,59,60,60,60,60,60,61,61,61,61,61,61,61,62,62,63,63,64,64,65,65,65,65,65,66,66,66,66,66,66,66,67,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,69,70,70,70,70,70,70,72,72,72,72,72,72,73,73,74,74,75,75,75,75,75,75,75,75,75,75,76,76,76,76,76,76,77,78,78,79,79,79,80,80,80,80,81,81,81,81,81,82,83,83,84,86,87,87,87,88,89,89,89,89,89,89,89,90,90,90,90,91,92,92,93};+const uint8_t snow_run[115][4] = {{0,43,1,255},{1,42,1,255},{1,44,1,255},{2,43,1,255},{15,37,1,255},{15,55,1,255},{15,57,1,255},{16,56,1,255},{17,55,1,255},{17,57,1,255},{19,24,3,255},{19,59,3,255},{20,23,1,255},{20,25,1,255},{20,58,1,255},{20,60,1,255},{26,25,1,255},{33,6,1,255},{42,61,1,255},{44,30,1,255},{45,29,1,255},{45,31,1,255},{46,30,1,255},{53,25,3,255},{54,24,1,255},{54,26,1,255},{65,43,1,255},{65,45,1,255},{66,44,1,255},{67,1,1,255},{67,43,1,255},{67,45,1,255},{72,8,1,255},{79,12,1,255},{80,11,1,255},{80,13,1,255},{81,12,1,255},{83,55,1,255},{84,54,1,255},{84,56,1,255},{85,55,1,255},{92,12,1,255},{92,14,1,255},{92,56,1,255},{93,13,1,255},{94,12,1,255},{94,14,1,255},{104,8,1,255},{104,46,1,255},{105,45,1,255},{105,47,1,255},{106,46,1,255},{127,51,1,255},{128,38,3,255},{129,37,1,255},{129,39,1,255},{130,25,1,255},{136,18,1,255},{136,20,1,255},{137,19,1,255},{138,18,1,255},{138,20,1,255},{146,3,1,255},{147,2,1,255},{147,4,1,255},{148,3,1,255},{155,41,1,255},{156,40,1,255},{156,42,1,255},{157,41,1,255},{167,0,1,255},{173,13,1,255},{173,15,1,255},{174,14,1,255},{175,13,1,255},{175,15,1,255},{178,5,1,255},{178,26,1,255},{183,24,1,255},{184,23,1,255},{184,25,1,255},{185,24,1,255},{193,42,1,255},{194,41,1,255},{194,43,1,255},{195,42,1,255},{200,54,1,255},{201,46,3,255},{202,45,1,255},{202,47,1,255},{204,38,1,255},{206,58,1,255},{208,22,1,255},{209,21,1,255},{209,23,1,255},{210,22,1,255},{226,43,1,255},{229,46,3,255},{230,12,3,255},{230,45,1,255},{230,47,1,255},{231,11,1,255},{231,13,1,255},{235,53,1,255},{239,6,1,255},{239,8,1,255},{240,7,1,255},{241,6,1,255},{241,8,1,255},{246,42,1,255},{247,41,1,255},{247,43,1,255},{248,28,1,255},{248,42,1,255},{252,7,1,255}};+const uint8_t snow_idx[257] = {0,1,3,4,4,4,4,4,4,4,4,4,4,4,4,4,7,8,10,10,12,16,16,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,20,22,23,23,23,23,23,23,23,24,26,26,26,26,26,26,26,26,26,26,26,28,29,32,32,32,32,32,33,33,33,33,33,33,33,34,36,37,37,38,40,41,41,41,41,41,41,41,44,45,47,47,47,47,47,47,47,47,47,47,49,51,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,53,54,56,57,57,57,57,57,57,59,60,62,62,62,62,62,62,62,62,63,65,66,66,66,66,66,66,66,67,69,70,70,70,70,70,70,70,70,70,70,71,71,71,71,71,71,73,74,76,76,76,78,78,78,78,78,79,81,82,82,82,82,82,82,82,82,83,85,86,86,86,86,86,87,88,90,90,91,91,92,92,93,95,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,97,97,97,98,101,103,103,103,103,104,104,104,104,106,107,109,109,109,109,109,110,112,114,114,114,114,115,115,115,115};const uint16_t biome_grass[256] = {0x8DCE,0x95EB,0xBDAA,0x8DB1,0x7E0B,0x85B0,0x6B87,0x8DCE,0xBDAA,0x8DCE,0x85B2,0x85B2,0x85B2,0x85B2,0x5647,0x5647,0x95EB,0xBDAA,0x7E0B,0x85B0,0x8DB1,0x5E47,0x5E47,0x6627,0x8DCE,0x8DB1,0x85B2,0x8DCC,0x8DCC,0x53C6,0x85B2,0x85B2,0x85CF,0x85CF,0x8DB1,0xBDAA,0xBDAA,0x9409,0x9409,0x9409,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x95EB,0xBDAA,0x8DB1,0x7E0B,0x85B0,0x6B87,0x8DCE,0xBDAA,0x8DCE,0x85B2,0x85B2,0x85B2,0x85B2,0x5647,0x5647,0x95EB,0xBDAA,0x7E0B,0x85B0,0x8DB1,0x5E47,0x5E47,0x6627,0x8DCE,0x8DB1,0x85B2,0x8DCC,0x8DCC,0x53C6,0x85B2,0x85B2,0x85B0,0x85B0,0x8DB1,0xBDAA,0xBDAA,0x9409,0x9409,0x9409,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE,0x8DCE};const uint16_t biome_foliage[256] = {0x7529,0x7545,0xAD25,0x6D0D,0x5D66,0x6D2C,0x6B87,0x7529,0xAD25,0x7529,0x650F,0x650F,0x650F,0x650F,0x2DC1,0x2DC1,0x7545,0xAD25,0x5D66,0x6D2C,0x6D0D,0x35C1,0x35C1,0x3DC1,0x7529,0x6D0D,0x650F,0x6D48,0x6D48,0x5D66,0x650F,0x650F,0x6D2B,0x6D2B,0x6D0D,0xAD25,0xAD25,0x9C09,0x9C09,0x9C09,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7545,0xAD25,0x6D0D,0x5D66,0x6D2C,0x6B87,0x7529,0xAD25,0x7529,0x650F,0x650F,0x650F,0x650F,0x2DC1,0x2DC1,0x7545,0xAD25,0x5D66,0x6D2C,0x6D0D,0x35C1,0x35C1,0x3DC1,0x7529,0x6D0D,0x650F,0x6D48,0x6D48,0x5D66,0x650F,0x650F,0x6D2C,0x6D2C,0x6D0D,0xAD25,0xAD25,0x9C09,0x9C09,0x9C09,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529,0x7529};const uint16_t biome_water[256] = {0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xE7F5,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xE7F5,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF};const int8_t biome_temp[256] = {25,40,100,10,35,12,40,25,100,25,0,0,0,0,45,45,40,100,35,12,10,48,48,48,25,10,2,30,30,35,-25,-25,15,15,10,60,50,100,100,100,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,40,100,10,35,12,40,25,100,25,0,0,0,0,45,45,40,100,35,12,10,48,48,48,25,10,2,30,30,35,-25,-25,15,15,10,60,50,100,100,100,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25}; /* x 50 */+const uint8_t biome_rain[256] = {1,1,0,1,1,1,1,1,0,0,3,3,3,3,1,1,1,0,1,1,1,1,1,1,1,1,3,1,1,1,3,3,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,0,0,3,3,3,3,1,1,1,0,1,1,1,1,1,1,1,1,3,1,1,1,3,3,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};diff --git a/games/numblocks/src/data.h b/games/numblocks/src/data.hindex 94867dbd..4c67674f 100644--- a/games/numblocks/src/data.h+++ b/games/numblocks/src/data.h@@ -20,6 +20,9 @@ extern const uint8_t blk_level[B_COUNT], blk_hard[B_COUNT], blk_id[B_COUNT], blk/* blk_flags: bits 0-2 the tint (1 grass, 2 foliage, 3 spruce, 4 birch, 5 water, 6 lily pad) */extern const uint16_t biome_grass[256], biome_foliage[256], biome_water[256];extern const int8_t biome_temp[256]; /* temperature x 50 */+extern const uint8_t biome_rain[256]; /* 1: it rains (or snows), 2: a snowy biome */+/* rain and snow: runs down a texel column {row, column, length, alpha}, by row; idx: the first run at or below a row */+extern const uint8_t rain_run[][4], snow_run[][4], rain_idx[257], snow_idx[257];#define BF_OPAQUE 8#define BF_SOLID 16#define BF_TINT 7diff --git a/games/numblocks/src/entity.c b/games/numblocks/src/entity.cindex cb7080a0..896c8142 100644--- a/games/numblocks/src/entity.c+++ b/games/numblocks/src/entity.c@@ -8,9 +8,7 @@Entity ents[N_ENT];-/* ---------------------------------------------------------------- particles (EntityDiggingFX) */-typedef struct { float x, y, z, vx, vy, vz; uint16_t c; uint8_t age, life; } Particle;-#define N_PART 32+/* ---------------------------------------------------------------- particles (EntityDiggingFX, EntityRainFX) */Particle parts[N_PART];/* breaking a block: its bits, coloured like its texture, fly out and fall (EffectRenderer.addBlockDestroyEffects) */@@ -33,17 +31,49 @@ void particles_break(int x, int y, int z, int b) {}}+/* EntityRenderer.addRainParticles: drops splash on whatever the rain falls on+ * within 10 blocks, up to 100 a tick in a full downpour (half with Fast+ * graphics); here only as many as there are free particles */+static void rain_splashes(void) {+ float f = opt.fancy ? rain_str : rain_str / 2;+ int n = (int)(100 * f * f), px = (int)floorf(pl.x), py = (int)floorf(pl.y), pz = (int)floorf(pl.z);+ for (int i = 0; i < N_PART && n > 0; i++) {+ Particle *p = &parts[i];+ if (p->age < (p->life & ~RAIN_DROP)) continue;+ /* a free one: look for where it lands (a few tries, as most of the 100 would) */+ for (int k = 0; k < 4 && n > 0; k++, n--) {+ int x = px + rnd(10) - rnd(10), z = pz + rnd(10) - rnd(10), y = world_rain_top(x, z);+ if (y > py + 10 || y < py - 10 || !world_loaded(x, y - 1, z)) continue;+ int lx = x - vc_x0, lz = z - vc_z0, below = world_get(x, y - 1, z);+ if (biome_rain[vbiome[lz * VCX + lx]] != 1 || temp_at(x, y, z) < 0.15f || below == B_AIR || is_lava(below)) continue;+ float b[6], top = (float)y;+ if (block_box(x, y - 1, z, b)) top = b[4];+ p->x = x + rndf(), p->y = top + 0.1f, p->z = z + rndf();+ p->vx = (rndf() - 0.5f) * 0.03f, p->vz = (rndf() - 0.5f) * 0.03f, p->vy = rndf() * 0.2f + 0.1f;+ p->c = 0x1A59; /* (24, 72, 204), the splash sprites' blue */+ p->age = 0;+ p->life = (uint8_t)(RAIN_DROP | (int)(8 / (rndf() * 0.8f + 0.2f)));+ break;+ }+ }+}+static void particles_tick(void) {+ if (rain_str > 0) rain_splashes();for (int i = 0; i < N_PART; i++) {Particle *p = &parts[i];- if (p->age >= p->life) continue;+ bool drop = p->life & RAIN_DROP;+ if (p->age >= (p->life & ~RAIN_DROP)) continue;p->age++;- p->vy -= 0.04f;+ p->vy -= drop ? 0.06f : 0.04f;float np[3] = {p->x, p->y, p->z}, v[3] = {p->vx, p->vy, p->vz};bool ground = phys_move(np, v, 0.1f, 0.1f);p->x = np[0], p->y = np[1], p->z = np[2];p->vx = v[0] * 0.98f, p->vy = v[1] * 0.98f, p->vz = v[2] * 0.98f;- if (ground) p->vx *= 0.7f, p->vz *= 0.7f;+ if (ground) {+ p->vx *= 0.7f, p->vz *= 0.7f;+ if (drop && rnd(2)) p->age = p->life & ~RAIN_DROP; /* half the drops are gone when they land */+ }}}diff --git a/games/numblocks/src/genstub.c b/games/numblocks/src/genstub.cindex 022f038e..6f521f01 100644--- a/games/numblocks/src/genstub.c+++ b/games/numblocks/src/genstub.c@@ -76,3 +76,4 @@ void gen_slab(int cx, int cz, int y0, int h, uint8_t *out) {}}}+float gen_temp_noise(int x, int z) { return 0; }diff --git a/games/numblocks/src/mob.c b/games/numblocks/src/mob.cindex bee91a31..9a2cfcb9 100644--- a/games/numblocks/src/mob.c+++ b/games/numblocks/src/mob.c@@ -180,20 +180,14 @@ int mob_parts(const Entity *e, float pt, Part *o) {extern uint32_t game_time;static inline int ifl(float v) { return (int)floorf(v); }-static bool daylight(void) {- int t = (int)(game_time % 24000);- return t < 12300 || t > 23850;-}+/* World.isDaytime */+static bool daylight(void) { return sky_sub() < 4; }/* the light where a mob would stand: sky light less the night's darkness */static int light_there(int x, int y, int z) {if (!world_loaded(x, y, z)) return 15;int i = VC_I(x - vc_x0, y - vc_y0, z - vc_z0);int sky = light_at(i), blk = block_light_at(i);- /* World.calculateSkylightSubtracted: 0 at noon, 11 at midnight */- int t = (int)(game_time % 24000);- int sub = t < 12000 ? 0 : t < 13800 ? (t - 12000) * 11 / 1800 : t < 22200 ? 11 : (24000 - t) * 11 / 1800;- if (t >= 23999) sub = 0;- sky -= sub;+ sky -= sky_sub();return sky > blk ? sky : blk;}static bool can_stand(int x, int y, int z) {@@ -232,6 +226,11 @@ void mobs_spawn(void) {if (!can_stand(x, y, z)) continue;int below = world_get(x, y - 1, z);int light = light_there(x, y, z);+ /* EntityMob.isValidLightLevel: in a storm, the sky counts as night's */+ if (thunder_str * rain_str > 0.9f) {+ int i = VC_I(x - vc_x0, y - vc_y0, z - vc_z0), sky = light_at(i) - 10, blk = block_light_at(i);+ light = sky > blk ? sky : blk;+ }if (opt.difficulty > 0 && count(true) < 4 && light <= rnd(8) && below != B_BEDROCK) {static const uint8_t kinds[4] = {E_ZOMBIE, E_SKELETON, E_CREEPER, E_SPIDER};int t = kinds[rnd(4)];@@ -605,7 +604,7 @@ void mob_tick(Entity *e) {if (e->fire < 160) e->fire = 160;}if (in_lava) e->fire = 300, hurt(e, 4, 0, 0);- if (in_water) e->fire = 0;+ if (in_water || rain_at(bx, by, bz) || rain_at(bx, ifl(e->y + 1.6f), bz)) e->fire = 0; /* Entity.isWet */if (e->fire > 0) {if (e->fire % 20 == 0) hurt(e, 1, 0, 0);e->fire--;diff --git a/games/numblocks/src/nb.h b/games/numblocks/src/nb.hindex 87107bfa..1a1eb816 100644--- a/games/numblocks/src/nb.h+++ b/games/numblocks/src/nb.h@@ -59,6 +59,7 @@ void gen_slab(int cx, int cz, int y0, int h, uint8_t *out); /* out[(y - y0) *int gen_biome(int x, int z);int gen_top(int x, int z);void gen_spawn(int *x, int *y, int *z);+float gen_temp_noise(int x, int z); /* BiomeGenBase.temperatureNoise at (x / 8, z / 8) *//* ---------------------------------------------------------------- the world (world.c) */#define VCX 40@@ -85,6 +86,8 @@ int world_get(int x, int y, int z); /* B_AIR outside the cache, B_BEDvoid world_set(int x, int y, int z, int b); /* a player's change: kept in the edit log */bool world_loaded(int x, int y, int z);bool world_pending(void); /* chunks still being made after a move */+int world_rain_top(int x, int z); /* the first y above what rain lands on, 255 if unknown */+void *world_scratch(uint32_t n); /* n bytes free while a frame is drawn, or NULL *//* ---------------------------------------------------------------- items (inv.c) */typedef struct { uint16_t id, aux; } Stack; /* aux: how many; for tools and armour, their damage (one) */@@ -165,7 +168,12 @@ extern Entity ents[N_ENT];Entity *ent_new(int type, float x, float y, float z);void ent_drop(int id, int count, int dmg, float x, float y, float z, bool thrown);void ents_tick(void);-void particles_break(int x, int y, int z, int b); /* a block's bits flying out */+/* particles: a block's bits when it breaks, rain splashing (life + RAIN_DROP) */+typedef struct { float x, y, z, vx, vy, vz; uint16_t c; uint8_t age, life; } Particle;+#define N_PART 32+#define RAIN_DROP 128+extern Particle parts[N_PART];+void particles_break(int x, int y, int z, int b);void mob_tick(Entity *e);void mobs_spawn(void);void explode(float x, float y, float z, float power);@@ -179,7 +187,20 @@ void player_respawn(void);/* ---------------------------------------------------------------- liquids and growing (tick.c) */void fluid_schedule(int x, int y, int z); /* a liquid there may move */-void world_tick(void); /* 20 a second: liquids, random block ticks */+void world_tick(void); /* 20 a second: weather, liquids, random block ticks */++/* the weather (World.updateWeather), saved with the world */+typedef struct {+ int32_t rain_time, thunder_time; /* ticks until it starts or stops */+ uint8_t raining, thundering, pad[2];+} Weather;+extern Weather weather;+extern float rain_str, thunder_str; /* how hard it rains, how stormy: 0 to 1, 0.01 a tick */+void weather_clear(void); /* after a night's sleep */+float celestial(uint32_t t); /* the sun's angle: 0 noon, 0.5 midnight */+int sky_sub(void); /* how much darker the sky light is: 0 by day, 11 at night */+float temp_at(int x, int y, int z); /* the biome's temperature there */+bool rain_at(int x, int y, int z); /* rain (not snow) falls on it */void neighbours_changed(int x, int y, int z);void break_block_at(int x, int y, int z, bool drops);diff --git a/games/numblocks/src/player.c b/games/numblocks/src/player.cindex a6bb84f8..3fb1df6b 100644--- a/games/numblocks/src/player.c+++ b/games/numblocks/src/player.c@@ -431,10 +431,9 @@ static void eat_done(void) {use_up();}-/* EntityPlayer.trySleep: at night, with no monster within 8 blocks; the bed is the new spawn point */+/* EntityPlayer.trySleep: at night (or in a storm), with no monster within 8 blocks; the bed is the new spawn point */static void sleep_in(int x, int y, int z) {- int t = (int)(game_time % 24000);- if (t < 12541 || t > 23458) {+ if (sky_sub() < 4) {gui_message("You can only sleep at night");return;}@@ -633,7 +632,9 @@ static void hazards(float fell_from) {player_hurt(4, DMG_LAVA);pl.fire = 300;}- if (pl.in_water) pl.fire = 0;+ if (pl.in_water || rain_at((int)floorf(pl.x), (int)floorf(pl.y), (int)floorf(pl.z)) ||+ rain_at((int)floorf(pl.x), (int)floorf(pl.y + 1.8f), (int)floorf(pl.z)))+ pl.fire = 0; /* Entity.isWet */if (pl.fire > 0) {if (pl.fire % 20 == 0) player_hurt(1, DMG_FIRE);pl.fire--;@@ -652,6 +653,7 @@ void player_tick(uint32_t keys, uint32_t pressed) {/* asleep: after 100 ticks the night is over (WorldServer.wakeAllPlayers); a key gets you up */if (++pl.sleep_timer >= 100) {game_time += 24000 - game_time % 24000;+ weather_clear();pl.sleep_timer = 0;pl.y += 0.5f;} else if (pressed & (K_USE | K_ATTACK | K_JUMP)) pl.sleep_timer = 0, pl.y += 0.5f;diff --git a/games/numblocks/src/render.c b/games/numblocks/src/render.cindex 52b7ff4b..c8bdfe67 100644--- a/games/numblocks/src/render.c+++ b/games/numblocks/src/render.c@@ -26,6 +26,8 @@ static int shade[4][16]; /* face shade x sky light level -> 0..32 */static int shade_blk[4][16]; /* face shade x block light level -> 0..32 */static float sun_x, sun_y, sun_z; /* towards the sun */static float cloud_off;+static int cloud_r, cloud_g, cloud_b; /* the clouds' colour (0..255) */+static float sun_a; /* how much of the sun or moon shows (rain hides it) */static bool night;static int under_water;static int cam_x, cam_y, cam_z, cam_i, cam_b; /* the camera's cell, its index (-1 outside the cache), its block */@@ -101,8 +103,8 @@ static uint16_t sky(float dx, float dy, float dz, float len) {if (under_water) return pack(r / 4, g / 3, b / 2 + 40);/* the sun (or the moon): a square 1/3 of the way to the horizon, as in 1.8 */float sd = (dx * sun_x + dy * sun_y + dz * sun_z) / len;- if (sd > 0.94f) {- float s = sd > 0.985f ? 1.0f : (sd - 0.94f) / 0.045f;+ if (sd > 0.94f && sun_a > 0) {+ float s = (sd > 0.985f ? 1.0f : (sd - 0.94f) / 0.045f) * sun_a; /* (hidden by rain) */if (night) r += (int)(190 * s), g += (int)(200 * s), b += (int)(210 * s);else r += (int)(255 * s), g += (int)(250 * s), b += (int)(200 * s);}@@ -115,11 +117,10 @@ static uint16_t sky(float dx, float dy, float dz, float len) {int ix = (int)floorf(cx / 12) & 255, iz = (int)floorf(cz / 12) & 255;extern const uint8_t clouds[256 * 256 / 8];if (clouds[(iz * 256 + ix) >> 3] & (1 << (ix & 7))) {- int w = night ? 60 : 255;float a = 0.8f * (1 - dist / 200);- r += (int)((w - r) * a);- g += (int)((w - g) * a);- b += (int)((w - b) * a);+ r += (int)((cloud_r - r) * a);+ g += (int)((cloud_g - g) * a);+ b += (int)((cloud_b - b) * a);}}}@@ -921,17 +922,15 @@ static bool item_hit(const Draw *dr, const float *d, float *best_t, uint16_t *co}/* the particles: little squares, a tenth of a block, lit where they are */-typedef struct { float x, y, z, vx, vy, vz; uint16_t c; uint8_t age, life; } Particle;-extern Particle parts[32];static void particles_strip(int py0, int rows, uint16_t (*cb)[RW], float (*zb)[RW]) {- for (int i = 0; i < 32; i++) {+ for (int i = 0; i < N_PART; i++) {const Particle *p = &parts[i];- if (p->age >= p->life) continue;+ if (p->age >= (p->life & ~RAIN_DROP)) continue;float x = p->x - vc_x0, y = p->y - vc_y0, z = p->z - vc_z0, sx, sy;if (!project(x, y, z, &sx, &sy)) continue;float rx = x - ox, ry = y - oy, rz = z - oz;float t = rx * fwx + ry * fwy + rz * fwz; /* (the ray's length along the view, as zbuf keeps it) */- int half = (int)(0.05f / t / TAN_V * RH / 2 + 0.5f);+ int half = p->life & RAIN_DROP ? 1 : (int)(0.05f / t / TAN_V * RH / 2 + 0.5f); /* (a drop: a texel or two) */if (half < 1) half = 1;int cx = (int)floorf(x), cy = (int)floorf(y), cz = (int)floorf(z);int lb = (unsigned)cx < VCX && (unsigned)cy < VCY && (unsigned)cz < VCZ ? vl[VC_I(cx, cy, cz)] : 15;@@ -946,6 +945,167 @@ static void particles_strip(int py0, int rows, uint16_t (*cb)[RW], float (*zb)[R}}+/* ---------------------------------------------------------------- rain and snow */+/* EntityRenderer.renderRainSnow: around the player (10 blocks with Fancy+ * graphics, 5 with Fast), every column where it rains or snows has a sheet one+ * block wide turned towards the player, from the ground (or 10 blocks down)+ * to 10 blocks up, with rain.png scrolling down it, or snow.png drifting.+ * The textures' streaks and flakes are drawn as thin lines, fainter where+ * they are thinner than a pixel. The sheets live in the chunk buffer, which+ * nothing else uses while a frame is drawn. */+typedef struct {+ float cx, cz, hx, hz; /* centre (cache coordinates), half the width across */+ float v, u; /* texture row at y = 0 (scrolling), snow's drift across */+ int16_t y0, y1; /* bottom, top (cache y) */+ uint16_t col; /* lit colour */+ uint8_t alpha, snow;+ uint8_t sx0, sx1, sy0, sy1; /* where it is on the picture */+} Sheet;+extern uint32_t game_time;+static Sheet *sheets;+static int nsheets;++static uint32_t col_hash(int x, int z) {+ uint32_t h = (uint32_t)x * 3121u * (uint32_t)x + (uint32_t)x * 45238971u;+ h ^= (uint32_t)z * (uint32_t)z * 418711u + (uint32_t)z * 13761u;+ h = (h ^ (h >> 15)) * 2246822519u;+ return h ^ (h >> 13);+}++static void rain_frame(void) {+ nsheets = 0;+ if (rain_str <= 0 || under_water) return;+ int nmax = 6144 / (int)sizeof(Sheet);+ sheets = (Sheet *)world_scratch(nmax * sizeof(Sheet));+ if (!sheets) return;+ int r = opt.fancy ? 10 : 5;+ int px = (int)floorf(pl.x), pz = (int)floorf(pl.z), j = (int)floorf(pl.y), l = (int)floorf(oy + vc_y0 - 1.62f);+ float cnt = (float)(game_time % 100000) + tick_frac;+ /* nearest first, ring by ring, in case they do not all fit */+ for (int d = 1; d <= r; d++)+ for (int dz = -d; dz <= d; dz++)+ for (int dx = -d; dx <= d; dx += (dz == -d || dz == d) ? 1 : 2 * d) {+ if (nsheets >= nmax) return;+ int wx = px + dx, wz = pz + dz, lx = wx - vc_x0, lz = wz - vc_z0;+ if ((unsigned)lx >= VCX || (unsigned)lz >= VCZ || !(biome_rain[vbiome[lz * VCX + lx]] & 1)) continue;+ int top = world_rain_top(wx, wz);+ if (top > WORLD_H) continue;+ int y0 = j - r > top ? j - r : top, y1 = j + r > top ? j + r : top;+ if (y0 == y1) continue;+ Sheet *s = &sheets[nsheets];+ float n = 0.5f / sqrtf((float)(dx * dx + dz * dz));+ s->cx = lx + 0.5f, s->cz = lz + 0.5f, s->hx = -dz * n, s->hz = dx * n;+ /* in front of the camera at all? */+ float sx[4], sy[4];+ int in = 0;+ for (int k = 0; k < 4; k++) {+ float x = s->cx + (k & 1 ? s->hx : -s->hx), z = s->cz + (k & 1 ? s->hz : -s->hz);+ float y = (float)((k & 2 ? y1 : y0) - vc_y0);+ in += project(x, y, z, &sx[k], &sy[k]);+ }+ if (!in) continue;+ float ax = RW, bx = -1, ay = RH, by = -1;+ if (in < 4) ax = 0, bx = RW - 1, ay = 0, by = RH - 1;+ else+ for (int k = 0; k < 4; k++) {+ if (sx[k] < ax) ax = sx[k];+ if (sx[k] > bx) bx = sx[k];+ if (sy[k] < ay) ay = sy[k];+ if (sy[k] > by) by = sy[k];+ }+ if (bx < 0 || ax >= RW || by < 0 || ay >= RH) continue;+ s->sx0 = (uint8_t)(ax < 0 ? 0 : ax), s->sx1 = (uint8_t)(bx >= RW - 1 ? RW - 1 : bx);+ s->sy0 = (uint8_t)(ay < 0 ? 0 : ay), s->sy1 = (uint8_t)(by >= RH - 1 ? RH - 1 : by);+ s->y0 = (int16_t)(y0 - vc_y0), s->y1 = (int16_t)(y1 - vc_y0);+ float fx = wx + 0.5f - pl.x, fz = wz + 0.5f - pl.z, f = (fx * fx + fz * fz) / (float)(r * r);+ uint32_t h = col_hash(wx, wz);+ float rnd1 = (h & 0xFFFF) / 65536.0f, rnd2 = (h >> 16) / 65536.0f;+ /* the light where the sheet meets the player's height, or the ground */+ int ly = (top > l ? top : l) - vc_y0, lb = 15;+ if ((unsigned)ly < VCY) lb = vl[VC_I(lx, ly, lz)];+ s->snow = temp_at(wx, y0, wz) < 0.15f;+ if (!s->snow) {+ /* rows scroll down 3 to 4 blocks a second... (d5 in renderRainSnow) */+ float d5 = ((float)(((uint32_t)cnt + h) & 31) + (cnt - floorf(cnt))) / 32 * (3 + rnd1);+ s->v = d5 * 256, s->u = 0;+ s->alpha = (uint8_t)(((1 - f) * 0.5f + 0.5f) * rain_str * 255);+ s->col = shade565(pack(70, 103, 195), light_shade(0, lb));+ } else {+ /* ...snow drifts slowly, and sideways */+ float g1 = rnd2 * 2 - 1, g2 = rnd1 * 2 - 1;+ float d8 = -((float)((uint32_t)cnt & 511) + (cnt - floorf(cnt))) / 512;+ float d9 = rnd1 + cnt * 0.01f * g1, d10 = rnd2 + cnt * g2 * 0.001f;+ s->v = (d8 + d10) * 256, s->u = d9 - floorf(d9);+ s->alpha = (uint8_t)(((1 - f) * 0.3f + 0.5f) * rain_str * 255);+ int sk = lb & 15, bk = lb >> 4;+ s->col = shade565(0xFFFF, light_shade(0, ((sk * 3 + 15) / 4) | ((bk * 3 + 15) / 4) << 4));+ }+ nsheets++;+ }+}++/* the height (cache y) on the line down through (x, z) seen at picture row py */+static float row_height(float x, float z, float py) {+ float k = (1 - 2 * py / RH) * TAN_V, rx = x - ox, rz = z - oz;+ float d = upy - k * fwy;+ if (fabsf(d) < 1e-4f) return 1e9f;+ return oy + (k * (rx * fwx + rz * fwz) - (rx * upx + rz * upz)) / d;+}++static void rain_strip(int py0, int rows, uint16_t (*cb)[RW], float (*zb)[RW]) {+ for (int n = 0; n < nsheets; n++) {+ const Sheet *s = &sheets[n];+ if (s->sy1 < py0 || s->sy0 >= py0 + rows) continue;+ const uint8_t(*run)[4] = s->snow ? snow_run : rain_run;+ const uint8_t *idx = s->snow ? snow_idx : rain_idx;+ /* the heights this strip shows, at both edges of the sheet */+ float ylo = 1e9f, yhi = -1e9f;+ for (int e = -1; e <= 1; e += 2)+ for (int k = 0; k <= 1; k++) {+ float y = row_height(s->cx + e * s->hx, s->cz + e * s->hz, (float)(py0 + k * rows));+ if (y < ylo) ylo = y;+ if (y > yhi) yhi = y;+ }+ if (ylo < s->y0) ylo = s->y0;+ if (yhi > s->y1) yhi = s->y1;+ if (ylo >= yhi) continue;+ /* texture rows: row = y * 64 + v; runs are at most 16 rows long */+ int r0 = (int)floorf(ylo * 64 + s->v) - 16, r1 = (int)ceilf(yhi * 64 + s->v);+ for (int base = (int)floorf(r0 / 256.0f) * 256; base <= r1; base += 256) {+ int lo = r0 - base < 0 ? 0 : r0 - base, hi = r1 - base > 255 ? 255 : r1 - base;+ for (int i = idx[lo]; i < idx[hi + 1]; i++) {+ float ya = (base + run[i][0] - s->v) / 64, yb = ya + run[i][2] / 64.0f;+ if (ya < s->y0) ya = s->y0;+ if (yb > s->y1) yb = s->y1;+ if (yb <= ya) continue;+ float u = (run[i][1] + 0.5f) / 64 + s->u;+ u = (u - floorf(u)) * 2 - 1;+ float x = s->cx + s->hx * u - ox, z = s->cz + s->hz * u - oz;+ float bz = x * fwx + z * fwz, bx = x * rgx + z * rgz, by = x * upx + z * upz;+ float za = bz + (ya - oy) * fwy, zb2 = bz + (yb - oy) * fwy;+ if (za < 0.05f || zb2 < 0.05f) continue;+ float t = (za + zb2) / 2;+ int sx = (int)((bx / t / TAN_H + 1) * RW / 2);+ if ((unsigned)sx >= RW) continue;+ float top = (1 - (by + (yb - oy) * upy) / zb2 / TAN_V) * RH / 2;+ float bot = (1 - (by + (ya - oy) * upy) / za / TAN_V) * RH / 2;+ /* how much of a pixel the texels cover: across, and down when shorter than one */+ float cover = RW / 2 / (TAN_H * t) / 64;+ if (cover > 1) cover = 1;+ int a = run[i][3] * s->alpha / 255;+ if (a <= 25) continue; /* 1.8's alpha test */+ int k0 = (int)floorf(top + 0.5f), k1 = (int)floorf(bot - 0.5f);+ float ak = a * cover * 32 / 255;+ if (k1 < k0) k0 = k1 = (int)floorf((top + bot) / 2), ak *= bot - top;+ int k = (int)(ak + 0.5f);+ if (k <= 0) continue;+ for (int py = k0 < py0 ? py0 : k0; py <= k1 && py < py0 + rows; py++)+ if (zb[py - py0][sx] > t) cb[py - py0][sx] = mix565(cb[py - py0][sx], s->col, k);+ }+ }+ }+}+static void ents_strip(int py0, int rows, uint16_t (*cb)[RW], float (*zb)[RW]) {Box bx[MAX_PARTS];particles_strip(py0, rows, cb, zb);@@ -976,6 +1136,7 @@ static void ents_strip(int py0, int rows, uint16_t (*cb)[RW], float (*zb)[RW]) {zb[py - py0][px] = t;}}+ rain_strip(py0, rows, cb, zb);}/* ---------------------------------------------------------------- the frame */@@ -1026,9 +1187,11 @@ void render_frame(const Camera *c, uint32_t tod) {float day = cosf(ang * 6.2831853f) * 2 + 0.5f;if (day < 0) day = 0;if (day > 1) day = 1;+ /* World.getSunBrightness: dimmer in rain, dimmer still in a storm */+ float rs = rain_str, ts = thunder_str * rain_str;float sunb = 1 - (cosf(ang * 6.2831853f) * 2 + 0.2f);sunb = sunb < 0 ? 0 : sunb > 1 ? 1 : sunb;- sunb = (1 - sunb) * 0.8f + 0.2f;+ sunb = (1 - sunb) * (1 - rs * 5 / 16) * (1 - ts * 5 / 16) * 0.8f + 0.2f;setup_light(sunb);night = day < 0.5f;/* the sun's direction: it rises in the east (+X) */@@ -1056,14 +1219,42 @@ void render_frame(const Camera *c, uint32_t tod) {case 4: R = tt, G = p, B = 1; break;default: R = 1, G = p, B = q; break;}- sky_r = (int)(R * day * 255);- sky_g = (int)(G * day * 255);- sky_b = (int)(B * day * 255);+ float sr = R * day, sg = G * day, sbl = B * day;+ /* World.getSkyColor: rain and storms turn it grey */+ if (rs > 0) {+ float lum = (sr * 0.3f + sg * 0.59f + sbl * 0.11f) * 0.6f, k = 1 - rs * 0.75f;+ sr = sr * k + lum * (1 - k), sg = sg * k + lum * (1 - k), sbl = sbl * k + lum * (1 - k);+ }+ if (ts > 0) {+ float lum = (sr * 0.3f + sg * 0.59f + sbl * 0.11f) * 0.2f, k = 1 - ts * 0.75f;+ sr = sr * k + lum * (1 - k), sg = sg * k + lum * (1 - k), sbl = sbl * k + lum * (1 - k);+ }+ sky_r = (int)(sr * 255);+ sky_g = (int)(sg * 255);+ sky_b = (int)(sbl * 255);float fr = 0.7529412f * (day * 0.94f + 0.06f), fg = 0.84705883f * (day * 0.94f + 0.06f), fb = 1.0f * (day * 0.91f + 0.09f);- /* 1.8 mixes the fog towards the sky at short view distances */- fr += (R * day - fr) * 0.26f;- fg += (G * day - fg) * 0.26f;- fb += (B * day - fb) * 0.26f;+ /* 1.8 mixes the fog towards the sky at short view distances, then darkens it in rain and storms */+ fr += (sr - fr) * 0.26f;+ fg += (sg - fg) * 0.26f;+ fb += (sbl - fb) * 0.26f;+ fr *= (1 - rs * 0.5f) * (1 - ts * 0.5f);+ fg *= (1 - rs * 0.5f) * (1 - ts * 0.5f);+ fb *= (1 - rs * 0.4f) * (1 - ts * 0.5f);+ /* World.getCloudColour */+ {+ float cr = 1, cg = 1, cbl = 1;+ if (rs > 0) {+ float lum = 0.6f, k = 1 - rs * 0.95f;+ cr = cg = cbl = k + lum * (1 - k);+ }+ cr *= day * 0.9f + 0.1f, cg *= day * 0.9f + 0.1f, cbl *= day * 0.85f + 0.15f;+ if (ts > 0) {+ float lum = (cr * 0.3f + cg * 0.59f + cbl * 0.11f) * 0.2f, k = 1 - ts * 0.95f;+ cr = cr * k + lum * (1 - k), cg = cg * k + lum * (1 - k), cbl = cbl * k + lum * (1 - k);+ }+ cloud_r = (int)(cr * 255), cloud_g = (int)(cg * 255), cloud_b = (int)(cbl * 255);+ }+ sun_a = 1 - rs;fog_r = (int)(fr * 255);fog_g = (int)(fg * 255);fog_b = (int)(fb * 255);@@ -1090,6 +1281,7 @@ void render_frame(const Camera *c, uint32_t tod) {if (brk_stage > 9) brk_stage = 9;}ents_frame();+ rain_frame();/* every other pixel of every other row is traced; the others come from* their neighbours when those met the same face (or the sky) */Sample *top = rows[0], *mid = rows[1], *bot = rows[2];diff --git a/games/numblocks/src/save.c b/games/numblocks/src/save.cindex c94b5638..2e2daa95 100644--- a/games/numblocks/src/save.c+++ b/games/numblocks/src/save.c@@ -1,4 +1,4 @@-/* Saving: the world's record (its seed, the time, the player, chests and+/* Saving: the world's record (its seed, the time, the weather, the player, chests and* furnaces) next to the records of its changed blocks (edits.c), and the* options. A world saves every 45 seconds of play, as Minecraft does, and* when you quit; block changes reach storage as they fill the journal. */@@ -17,6 +17,7 @@ typedef struct {uint16_t player_size, tiles_size;int64_t seed;uint32_t time;+ Weather weather;} Head;extern uint32_t game_time;@@ -28,7 +29,7 @@ bool save_world(void) {bool ok = edits_flush();uint32_t tl;void *t = tiles_data(&tl);- Head h = {{'N', 'B', 'W', '1'}, (uint16_t)sizeof pl, (uint16_t)tl, world_seed, game_time};+ Head h = {{'N', 'B', 'W', '1'}, (uint16_t)sizeof pl, (uint16_t)tl, world_seed, game_time, weather};/* one record: the head, the player, the tiles (written from a buffer made in the merge scratch) */uint32_t n = sizeof h + sizeof pl + tl;uint8_t *b = (uint8_t *)edits_scratch(n);@@ -69,6 +70,10 @@ bool load_world(void) {return false;world_seed = h.seed;game_time = h.time;+ /* World.calculateInitialWeather */+ weather = h.weather;+ rain_str = weather.raining ? 1 : 0;+ thunder_str = weather.thundering ? 1 : 0;memcpy(&pl, d + sizeof h, sizeof pl);memcpy(t, d + sizeof h + sizeof pl, tl);memset(ents, 0, sizeof ents);@@ -83,6 +88,8 @@ void new_world(int64_t seed, int mode) {memset(ents, 0, sizeof ents);world_seed = seed;game_time = 0;+ memset(&weather, 0, sizeof weather);+ rain_str = thunder_str = 0;world_new(seed, WORLD);player_spawn();pl.mode = (uint8_t)mode;diff --git a/games/numblocks/src/tick.c b/games/numblocks/src/tick.cindex b46a870a..f9f65d46 100644--- a/games/numblocks/src/tick.c+++ b/games/numblocks/src/tick.c@@ -1,7 +1,9 @@-/* The world's own changes: liquids flowing (BlockDynamicLiquid) and random+/* The world's own changes: liquids flowing (BlockDynamicLiquid), random* block ticks (WorldServer.updateBlocks: 3 random blocks a 16 x 16 x 16* section each tick): crops and saplings grow, grass spreads and dies,- * leaves far from a log decay, sugar cane and cactus grow. */+ * leaves far from a log decay, sugar cane and cactus grow; and the weather+ * (World.updateWeather): rain, thunder, snow piling up, water freezing. */+#include <math.h>#include <stdlib.h>#include "nb.h"@@ -252,6 +254,7 @@ static void random_tick(int x, int y, int z) {for (int dz = -4; dz <= 4 && !wet; dz++)for (int dx = -4; dx <= 4 && !wet; dx++)for (int dy = 0; dy <= 1 && !wet; dy++) wet = is_water(world_get(x + dx, y + dy, z + dz));+ if (rain_at(x, y + 1, z)) wet = true;if (wet != (b == B_FARMLAND_WET)) world_set(x, y, z, wet ? B_FARMLAND_WET : B_FARMLAND);else if (!wet && !(above >= B_WHEAT_0 && above <= B_WHEAT_7) && rnd(4) == 0) world_set(x, y, z, B_DIRT);return;@@ -289,7 +292,88 @@ static void random_tick(int x, int y, int z) {if (b == B_ICE && blight > 11) world_set(x, y, z, B_WATER);}+/* ---------------------------------------------------------------- weather */+Weather weather;+float rain_str, thunder_str;++/* the sun's angle in the sky (WorldProvider.calculateCelestialAngle) */+float celestial(uint32_t t) {+ float a = (t % 24000) / 24000.0f - 0.25f;+ if (a < 0) a += 1;+ return a + ((1 - (cosf(a * 3.14159265f) + 1) / 2) - a) / 3;+}++/* World.calculateSkylightSubtracted: 0 by day, 11 at night, more in rain and storms */+int sky_sub(void) {+ float f = 1 - (cosf(celestial(game_time) * 6.2831853f) * 2 + 0.5f);+ f = f < 0 ? 0 : f > 1 ? 1 : f;+ f = (1 - f) * (1 - rain_str * 5 / 16) * (1 - thunder_str * rain_str * 5 / 16);+ return (int)((1 - f) * 11);+}++/* BiomeGenBase.getFloatTemperature: colder higher up */+float temp_at(int x, int y, int z) {+ int lx = x - vc_x0, lz = z - vc_z0;+ int b = (unsigned)lx < VCX && (unsigned)lz < VCZ ? vbiome[lz * VCX + lx] : 1;+ float t = biome_temp[b] / 50.0f;+ if (y > 64) t -= (gen_temp_noise(x, z) * 4 + y - 64) * 0.05f / 30;+ return t;+}++/* World.canLightningStrike: rain falls here (not snow), out under the sky */+bool rain_at(int x, int y, int z) {+ if (rain_str <= 0.2f) return false;+ int lx = x - vc_x0, lz = z - vc_z0;+ if ((unsigned)lx >= VCX || (unsigned)lz >= VCZ) return false;+ int b = vbiome[lz * VCX + lx];+ if (biome_rain[b] != 1 || world_rain_top(x, z) > y) return false;+ return temp_at(x, y, z) > 0.15f;+}++/* World.updateWeather: clear for 10 minutes to 2.5 hours, then rain for 10 to 20;+ * storms come and go on their own clock but only show while it rains */+void weather_tick(void) {+ if (weather.thunder_time <= 0) weather.thunder_time = weather.thundering ? rnd(12000) + 3600 : rnd(168000) + 12000;+ else if (--weather.thunder_time <= 0) weather.thundering = !weather.thundering;+ thunder_str += weather.thundering ? 0.01f : -0.01f;+ thunder_str = thunder_str < 0 ? 0 : thunder_str > 1 ? 1 : thunder_str;+ if (weather.rain_time <= 0) weather.rain_time = weather.raining ? rnd(12000) + 12000 : rnd(168000) + 12000;+ else if (--weather.rain_time <= 0) weather.raining = !weather.raining;+ rain_str += weather.raining ? 0.01f : -0.01f;+ rain_str = rain_str < 0 ? 0 : rain_str > 1 ? 1 : rain_str;+}++/* WorldProvider.resetRainAndThunder: after a night's sleep */+void weather_clear(void) {+ weather.rain_time = weather.thunder_time = 0;+ weather.raining = weather.thundering = 0;+}++/* WorldServer.updateBlocks, one column in 16 chunks a tick: still water+ * freezes where it is cold, and snow settles while it falls */+static void freeze_tick(void) {+ if (rnd(16) >= VCX * VCZ / 256) return;+ int x = vc_x0 + rnd(VCX), z = vc_z0 + rnd(VCZ);+ int y = world_rain_top(x, z);+ if (y > WORLD_H || !world_loaded(x, y - 1, z) || !world_loaded(x, y, z)) return;+ int i = VC_I(x - vc_x0, y - vc_y0, z - vc_z0), below = world_get(x, y - 1, z);+ /* World.canBlockFreeze: still water with something other than water beside it */+ if (below == B_WATER && temp_at(x, y - 1, z) <= 0.15f && block_light_at(i - VCX * VCZ) < 10 &&+ !(is_water(world_get(x - 1, y - 1, z)) && is_water(world_get(x + 1, y - 1, z)) &&+ is_water(world_get(x, y - 1, z - 1)) && is_water(world_get(x, y - 1, z + 1)))) {+ world_set(x, y - 1, z, B_ICE);+ below = B_ICE;+ }+ /* World.canSnowAt and BlockSnow.canPlaceBlockAt: on leaves or a solid cube, not on ice */+ if (rain_str > 0.2f && world_get(x, y, z) == B_AIR && temp_at(x, y, z) <= 0.15f && block_light_at(i) < 10 &&+ below != B_ICE && below != B_PACKED_ICE &&+ (blk_model[below] == M_LEAVES || ((blk_flags[below] & BF_OPAQUE) && blk_model[below] == M_CUBE)))+ world_set(x, y, z, B_SNOW_LAYER);+}+void world_tick(void) {+ weather_tick();+ freeze_tick();fluids_tick();/* about 3 a section: the cache is VCX x VCY x VCZ blocks */int n = VCX * VCY * VCZ * 3 / 4096;diff --git a/games/numblocks/src/world.c b/games/numblocks/src/world.cindex 8e67478c..f0e3bdb7 100644--- a/games/numblocks/src/world.c+++ b/games/numblocks/src/world.c@@ -290,3 +290,26 @@ void world_set(int x, int y, int z, int b) {light_box(lx - 15, ly - 15, lz - 15, lx + 16, VCY, lz + 16);mac_box(lx, ly, lz, lx + 1, ly + 1, lz + 1);}++/* Chunk.getPrecipitationHeight: the first y above the blocks rain lands on+ * (anything that stops movement, and liquids: not plants, torches, snow+ * layers or rails). Above the cache only the sky light's top is known. */+static bool stops_rain(int b) {+ switch (blk_model[b]) {+ case M_NONE: case M_CROSS: case M_TORCH: case M_LAYER: case M_VINE: case M_FLAT: case M_LADDER: return false;+ default: return true;+ }+}+int world_rain_top(int x, int z) {+ int lx = x - vc_x0, lz = z - vc_z0;+ if ((unsigned)lx >= VCX || (unsigned)lz >= VCZ) return 255;+ int col = lz * VCX + lx, t = vtop[col];+ if (vpend[col]) return 255;+ if (t > vc_y0 + VCY) return t;+ for (int y = VCY - 1; y >= 0 && y + vc_y0 >= t; y--)+ if (stops_rain(vc[VC_I(lx, y, lz)])) return y + vc_y0 + 1;+ return t;+}++/* the chunk buffer, free while a frame is drawn (the rain uses it) */+void *world_scratch(uint32_t n) { return n <= sizeof slab32 ? slab32 : NULL; }diff --git a/games/numblocks/tests/play.c b/games/numblocks/tests/play.cindex 72845938..5e4975c3 100644--- a/games/numblocks/tests/play.c+++ b/games/numblocks/tests/play.c@@ -33,7 +33,7 @@ static uint32_t key_bit(const char *s) {int main(int argc, char **argv) {const char *out = "build/play", *shots = "";- int give = 0, title_screen = 0, mobs = 0, start_time = -1, torches = 0, water = 0, creative = 0, build = 0;+ int give = 0, title_screen = 0, mobs = 0, start_time = -1, torches = 0, water = 0, creative = 0, build = 0, rain = 0;float hurt = 0;int frames = 60, mspf = 50;for (int i = 1; i < argc; i++) {@@ -48,6 +48,8 @@ int main(int argc, char **argv) {else if (!strcmp(argv[i], "--water")) water = 1;else if (!strcmp(argv[i], "--creative")) creative = 1;else if (!strcmp(argv[i], "--build")) build = 1;+ else if (!strcmp(argv[i], "--rain")) rain = 1;+ else if (!strcmp(argv[i], "--storm")) rain = 2;else if (!strcmp(argv[i], "--time") && i + 1 < argc) start_time = atoi(argv[++i]);else if (!strcmp(argv[i], "--hurt") && i + 1 < argc) hurt = (float)atof(argv[++i]);else if (!strcmp(argv[i], "--keys") && i + 1 < argc) {@@ -80,6 +82,11 @@ int main(int argc, char **argv) {game_time = (uint32_t)start_time;}if (creative) pl.mode = 1;+ if (rain) {+ /* raining (and storming) from the start, for long enough */+ weather.raining = 1, weather.rain_time = 24000, rain_str = 1;+ if (rain == 2) weather.thundering = 1, weather.thunder_time = 24000, thunder_str = 1;+ }if (build) {/* a cleared field with the shaped blocks in a row: stairs, door, bed, chest, furnace, fence, pane, ladder */int fy = (int)pl.y, px = (int)pl.x, pz = (int)pl.z;diff --git a/games/numblocks/tests/unit.c b/games/numblocks/tests/unit.cindex c57811a2..b8975670 100644--- a/games/numblocks/tests/unit.c+++ b/games/numblocks/tests/unit.c@@ -149,6 +149,45 @@ int main(void) {CHECK(calves == 1);plat_remove_prefix("ut3");}+ {+ /* weather: the clock, the strength, the light, and where rain falls */+ extern uint32_t game_time;+ world_new(0, "ut4");+ world_follow(8, 70, 8);+ for (int i = 0; i < VCX * VCZ; i++) vbiome[i] = 1; /* plains */+ memset(&weather, 0, sizeof weather);+ rain_str = thunder_str = 0;+ game_time = 6000; /* noon */+ CHECK(sky_sub() == 0);+ world_tick();+ CHECK(!weather.raining && weather.rain_time >= 12000 - 1 && weather.rain_time < 180000);+ weather.rain_time = 1;+ world_tick();+ CHECK(weather.raining && rain_str > 0 && rain_str < 0.05f);+ for (int t = 0; t < 120; t++) world_tick();+ CHECK(rain_str == 1 && sky_sub() == 3); /* rain alone: still day, no sleeping */+ weather.thundering = 1, thunder_str = 1;+ CHECK(sky_sub() >= 4); /* a storm: dark enough to sleep */+ int y = 70;+ for (int z = 0; z <= 4; z++)+ for (int x = 0; x <= 4; x++) {+ world_set(x, y - 1, z, B_STONE);+ for (int k = 0; k < 6; k++) world_set(x, y + k, z, B_AIR);+ }+ CHECK(rain_at(2, y, 2));+ world_set(2, y + 3, 2, B_LEAVES_OAK); /* leaves keep it off */+ CHECK(!rain_at(2, y, 2) && world_rain_top(2, 2) == y + 4);+ world_set(3, y, 3, B_TALL_GRASS); /* plants do not */+ CHECK(world_rain_top(3, 3) == y);+ vbiome[(2 - vc_z0) * VCX + 1 - vc_x0] = 2; /* deserts get none */+ CHECK(!rain_at(1, y, 2));+ vbiome[(2 - vc_z0) * VCX + 1 - vc_x0] = 12; /* snowy biomes get snow */+ CHECK(!rain_at(1, y, 2));+ weather_clear();+ world_tick();+ CHECK(!weather.raining && !weather.thundering);+ plat_remove_prefix("ut4");+ }printf("%s (%d recipes)\n", fails ? "FAILED" : "all good", N_RECIPES);return fails != 0;}diff --git a/games/numblocks/tools/pack.py b/games/numblocks/tools/pack.pyindex 73c93d96..c2f931f2 100644--- a/games/numblocks/tools/pack.py+++ b/games/numblocks/tools/pack.py@@ -678,12 +678,38 @@ def main():if a >= 128:bits[i >> 3] |= 1 << (i & 7)out.append('const uint8_t clouds[8192] = {' + ','.join(str(v) for v in bits) + '};')+ # rain and snow (64 x 256): their streaks and flakes as runs down a texel column,+ # {row, column, length, alpha}, by row; texels too faint to pass 1.8's alpha test (0.1) left out+ for name in ('rain', 'snow'):+ im = jar.image('environment/' + name)+ w, h = im.size+ px = im.load()+ runs = []+ for x in range(w):+ y = 0+ while y < h:+ if px[x, y][3] > 25:+ y0, al = y, []+ while y < h and px[x, y][3] > 25:+ al.append(px[x, y][3])+ y += 1+ runs.append((y0, x, len(al), round(sum(al) / len(al))))+ else:+ y += 1+ runs.sort()+ idx = [next((i for i, r in enumerate(runs) if r[0] >= row), len(runs)) for row in range(h + 1)]+ out.append(f'const uint8_t {name}_run[{len(runs)}][4] = {{' + ','.join('{%d,%d,%d,%d}' % r for r in runs) + '};')+ out.append(f'const uint8_t {name}_idx[{h + 1}] = {{' + ','.join(str(v) for v in idx) + '};')g, f, w = biome_colors(jar)out.append('const uint16_t biome_grass[256] = {' + ','.join(f'0x{rgb565(*c):04X}' for c in g) + '};')out.append('const uint16_t biome_foliage[256] = {' + ','.join(f'0x{rgb565(*c):04X}' for c in f) + '};')out.append('const uint16_t biome_water[256] = {' + ','.join(f'0x{rgb565(*c):04X}' for c in w) + '};')temps = [BIOMES.get(i & 127 if i >= 128 else i, (0.5, 0.5))[0] for i in range(256)]out.append('const int8_t biome_temp[256] = {' + ','.join(str(int(round(t * 50))) for t in temps) + '}; /* x 50 */')+ # BiomeGenBase.enableRain (off in deserts, savannas, mesas) and enableSnow; mutated biomes copy them+ no_rain, snowy = {2, 8, 9, 17, 35, 36, 37, 38, 39}, {10, 11, 12, 13, 26, 30, 31}+ rain = [(0 if (i & 127) in no_rain else 1) | (2 if (i & 127) in snowy else 0) for i in range(256)]+ out.append('const uint8_t biome_rain[256] = {' + ','.join(str(v) for v in rain) + '};')open(os.path.join(ROOT, 'src', 'data.c'), 'w').write('\n'.join(out) + '\n')h = ['/* Generated by tools/pack.py: textures and block tables (see data.c). */', '#ifndef NB_DATA_H',@@ -701,6 +727,9 @@ def main():'/* blk_flags: bits 0-2 the tint (1 grass, 2 foliage, 3 spruce, 4 birch, 5 water, 6 lily pad) */','extern const uint16_t biome_grass[256], biome_foliage[256], biome_water[256];','extern const int8_t biome_temp[256]; /* temperature x 50 */',+ 'extern const uint8_t biome_rain[256]; /* 1: it rains (or snows), 2: a snowy biome */',+ '/* rain and snow: runs down a texel column {row, column, length, alpha}, by row; idx: the first run at or below a row */',+ 'extern const uint8_t rain_run[][4], snow_run[][4], rain_idx[257], snow_idx[257];',f'#define BF_OPAQUE {BF_OPAQUE}', f'#define BF_SOLID {BF_SOLID}', '#define BF_TINT 7', '']for i, n in enumerate(names):h.append(f'#define TX_{n.upper().replace("@", "")} {i}')