Skip to content

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.

NumBlocks: mobs

Mason Chen71687d40dcc6
diff --git a/games/numblocks/Makefile b/games/numblocks/Makefile
index 7d7e29e6..e73dbfd1 100644
--- a/games/numblocks/Makefile
+++ b/games/numblocks/Makefile
@@ -10,7 +10,7 @@ BUILD_DIR = output
STRIP ?= arm-none-eabi-strip --strip-unneeded
CLIENT_JAR ?= client.jar
GEN ?= src/genstub.c
-GAME = src/main.c src/world.c src/edits.c src/render.c src/player.c src/phys.c src/inv.c src/entity.c src/gui.c src/save.c src/data.c $(GEN)
+GAME = src/main.c src/world.c src/edits.c src/render.c src/player.c src/phys.c src/inv.c src/entity.c src/mob.c src/gui.c src/save.c src/data.c $(GEN)
HEADERS = $(wildcard src/*.h) ../common/epsilon_app.h ../common/epsilon_files.h
CFLAGS = -std=gnu11 $(shell $(NWLINK) eadk-cflags-device)
diff --git a/games/numblocks/src/data.c b/games/numblocks/src/data.c
index ab450e86..2c2f39b4 100644
--- a/games/numblocks/src/data.c
+++ b/games/numblocks/src/data.c
@@ -1073,6 +1073,29 @@ const uint16_t group_planks[] = {14,15,16,17,18,19,0xFFFF};
const uint16_t group_wool[] = {67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,0xFFFF};
const uint16_t group_log[] = {35,39,43,47,183,187,0xFFFF};
const uint16_t group_sapling[] = {20,21,22,23,24,25,0xFFFF};
+const uint8_t skin_px[9][1024] = {
+ {0,0,0,0,119,122,167,170,170,170,170,170,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,167,85,167,170,170,169,153,170,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,87,149,167,170,170,255,255,170,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,90,167,119,117,170,255,255,170,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,87,151,89,117,170,255,255,170,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,119,153,85,117,170,255,255,170,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,151,117,169,117,170,170,170,170,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,119,153,153,119,170,170,170,170,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,153,153,87,85,117,149,154,119,85,117,153,153,119,122,167,170,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,153,153,119,87,119,87,51,151,117,119,153,153,167,85,167,170,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,151,121,151,121,55,51,51,83,151,121,151,121,87,149,167,170,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,121,119,153,87,51,51,51,85,117,153,119,151,90,167,119,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,153,153,154,85,243,63,243,63,85,169,153,153,87,151,89,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,153,151,149,149,53,163,58,149,89,89,121,153,119,153,85,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,151,167,85,169,85,121,167,151,154,85,122,121,151,117,169,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,153,149,85,167,170,170,169,169,122,85,85,149,169,153,153,154,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,204,204,255,255,0,0,0,0,161,170,170,26,136,136,136,136,0,0,0,0,18,33,170,170,0,0,0,0,0,0,0,0,204,204,255,255,0,0,0,0,161,170,170,26,136,136,136,136,0,0,0,0,17,17,170,170,0,0,0,0,0,0,0,0,204,204,255,255,0,0,0,0,161,170,170,26,136,136,136,136,0,0,0,0,17,33,170,170,0,0,0,0,0,0,0,0,204,204,255,255,0,0,0,0,161,170,170,26,136,136,136,136,0,0,0,0,18,33,170,170,0,0,0,0,0,0,238,238,204,204,238,238,204,236,68,132,36,89,153,34,68,68,34,34,17,34,68,68,34,33,68,68,17,17,0,0,0,0,238,238,204,204,238,238,204,204,132,72,34,146,41,17,132,136,18,17,17,34,136,72,33,33,132,72,17,17,0,0,0,0,238,238,204,204,238,238,204,204,136,72,17,34,36,17,136,136,17,17,17,33,132,72,18,17,132,72,17,17,0,0,0,0,238,238,204,204,238,238,204,204,136,136,17,33,20,17,136,136,17,20,66,33,132,72,18,33,132,72,17,17,0,0,0,0,238,238,204,204,238,238,238,238,136,136,68,17,20,68,136,136,33,20,66,17,85,117,51,51,87,85,51,51,0,0,0,0,238,238,236,206,238,238,238,238,136,136,68,33,20,66,136,136,65,20,66,18,85,117,83,51,117,85,51,51,0,0,0,0,238,238,204,204,238,238,204,204,136,136,20,65,18,66,136,136,33,36,65,20,87,117,83,83,117,85,83,53,0,0,0,0,238,238,204,204,238,238,204,204,132,72,20,65,18,66,132,136,17,36,65,20,87,85,51,83,117,117,51,51,0,0,0,0,238,238,204,204,238,238,204,204,132,72,17,65,18,65,132,72,17,17,17,17,87,87,51,83,85,117,51,51,0,0,0,0,221,238,204,204,238,221,102,102,132,68,68,36,33,65,132,72,68,20,68,33,85,87,51,51,85,85,83,83,0,0,0,0,221,221,102,102,221,221,102,102,238,238,204,204,236,65,228,238,236,46,68,206,85,87,51,53,87,87,83,83,0,0,0,0,221,221,102,102,221,221,102,102,238,238,204,204,204,78,238,238,204,236,196,204,85,85,53,85,87,85,83,83,0,0,0,0},
+ {0,0,0,0,119,124,199,188,221,221,221,221,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,199,68,199,204,13,0,0,208,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,71,164,199,204,13,0,0,208,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,76,199,119,116,13,0,0,208,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,71,167,74,116,13,0,0,208,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,119,170,68,116,13,0,0,208,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,167,132,186,116,13,0,0,208,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,135,170,170,119,221,221,221,221,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,153,170,56,85,101,148,172,118,85,131,170,153,119,124,199,188,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,153,170,134,38,102,38,17,150,98,104,170,153,199,68,199,204,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,150,138,151,139,22,17,17,33,184,121,168,105,71,164,199,204,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,121,101,169,70,17,17,18,34,100,154,86,151,76,199,119,116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,153,153,139,35,241,31,241,31,50,184,153,153,71,167,74,116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,153,151,149,133,19,209,29,162,88,89,121,153,119,170,68,116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,150,229,66,217,245,255,255,159,157,36,94,105,167,132,186,116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,153,148,82,215,221,221,217,200,125,34,34,148,217,170,170,157,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,98,104,0,0,0,0,0,0,0,0,0,0,0,85,131,170,153,0,0,0,98,104,0,0,0,0,0,0,0,0,0,0,184,121,0,0,0,0,0,0,0,0,0,0,0,98,104,170,153,0,0,0,184,121,0,0,0,0,0,0,0,0,0,119,119,119,119,0,0,0,0,0,0,0,0,0,0,184,121,168,105,0,0,119,119,119,119,0,0,0,0,0,0,0,0,199,199,199,199,0,0,0,0,0,0,0,0,0,0,100,154,86,151,0,0,199,199,199,199,0,0,0,0,0,0,0,0,71,71,71,71,0,0,0,0,206,238,204,0,0,204,238,238,204,124,199,204,71,71,71,71,0,0,0,0,0,0,0,0,76,76,76,76,0,0,0,0,0,0,238,12,192,238,0,0,0,112,12,0,76,76,76,76,0,0,0,0,0,0,0,0,71,71,71,71,0,0,0,0,238,238,204,206,236,204,238,238,204,124,196,204,71,71,71,71,0,0,0,0,0,0,0,0,119,119,119,119,0,0,0,0,0,0,206,236,206,236,0,0,0,192,4,0,119,119,119,119,0,0,0,0,0,0,0,0,167,167,167,167,0,0,0,0,238,238,236,206,236,206,238,238,204,124,196,204,167,167,167,167,0,0,0,0,0,0,0,0,135,135,135,135,0,0,0,0,0,0,192,192,12,12,0,0,0,112,7,0,135,135,135,135,0,0,0,0,0,0,0,0,101,101,101,101,0,0,0,0,0,0,224,12,224,14,0,0,0,112,10,0,101,101,101,101,0,0,0,0,0,0,0,0,102,102,102,102,0,0,0,0,0,0,0,0,0,0,0,0,0,112,8,0,102,102,102,102,0,0,0,0,0,0,0,0,153,153,153,153,0,0,0,0,0,0,0,0,0,0,0,0,0,80,6,0,153,153,153,153,0,0,0,0,0,0,0,0,153,153,153,153,0,0,0,0,0,0,0,0,0,0,0,0,0,96,6,0,153,153,153,153,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,138,83,85,70,201,106,87,53,168,154,121,199,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,106,104,98,102,18,97,41,134,166,154,121,76,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,91,51,227,146,40,151,61,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,238,117,213,209,43,103,210,51,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,187,106,25,101,18,57,93,56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,135,125,25,150,34,17,97,75,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,184,34,25,150,97,22,145,45,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,142,212,161,145,98,25,157,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,51,140,209,221,141,209,61,105,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,152,204,209,162,120,137,215,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,136,132,216,153,195,75,81,214,103,196,236,153,145,25,114,217,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,216,229,91,91,158,107,109,25,233,194,60,22,26,201,108,73,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,29,67,227,94,251,79,253,31,26,180,220,26,101,194,140,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,22,120,35,68,248,127,251,111,22,119,33,17,101,194,76,190,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,41,201,123,88,149,244,47,126,24,101,81,70,148,145,38,125,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,73,206,124,59,211,255,255,39,25,109,97,38,211,146,125,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,78,230,189,69,161,255,255,217,26,212,106,33,162,158,97,216,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,23,49,131,211,87,79,243,126,56,52,98,209,118,61,145,109,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,77,84,255,255,0,0,0,0,30,18,57,35,211,114,73,134,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,225,69,255,254,0,0,0,0,229,36,221,116,232,228,187,181,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,109,40,255,255,0,0,0,0,190,24,119,125,56,183,188,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,113,57,255,255,0,0,0,0,133,24,102,142,57,200,88,53,0,0,0,0,0,0,0,0,0,0,0,0,0,0,114,71,204,45,185,69,91,187,181,91,133,45,158,85,72,152,114,91,243,79,0,0,0,0,0,0,0,0,0,0,0,0,133,75,204,26,157,195,213,181,237,223,159,29,239,227,212,146,115,219,255,93,0,0,0,0,0,0,0,0,0,0,0,0,157,227,46,103,49,202,233,238,190,229,223,184,236,63,212,221,157,253,45,135,0,0,0,0,0,0,0,0,0,0,0,0,86,113,213,102,129,231,229,229,139,133,247,190,200,252,228,161,232,141,199,156,0,0,0,0,0,0,0,0,0,0,0,0,101,145,255,255,145,73,132,235,184,101,217,254,204,219,237,255,254,133,203,252,0,0,0,0,0,0,0,0,0,0,0,0,214,241,255,255,95,88,190,91,235,213,57,88,204,91,142,91,235,229,219,78,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,94,53,229,94,232,93,158,83,78,37,253,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,222,238,45,67,152,237,72,142,23,232,61,83,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,201,140,237,71,149,227,223,239,223,254,131,88,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,203,190,229,79,229,149,109,72,59,190,131,91,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,204,233,190,221,162,189,133,235,74,213,190,67,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,72,85,181,243,117,77,130,142,40,69,179,229,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,190,187,238,236,188,238,0,171,175,250,185,95,45,244,51,121,95,245,105,52,95,246,169,0,0,0,0,0,0,0,0,0,190,171,236,238,188,238,0,153,159,249,249,155,127,246,119,35,45,210,18,34,77,247,121,0,0,0,0,0,0,0,0,0,190,172,204,238,187,238,251,36,29,210,51,67,61,243,153,191,151,159,250,171,153,159,249,153,0,0,0,0,0,0,0,0,190,172,236,206,187,238,191,153,159,249,170,169,159,250,153,251,119,63,247,119,103,111,212,119,0,0,0,0,0,0,0,0,191,174,236,190,203,238,0,0,0,0,0,0,0,0,0,0,0,34,17,49,71,33,17,34,81,0,0,0,0,0,0,0,191,171,235,187,187,239,0,0,0,0,0,0,0,0,0,0,0,34,18,81,71,33,17,34,65,0,0,0,0,170,186,187,191,171,254,171,154,153,238,175,190,0,0,0,0,0,0,0,0,18,18,74,55,33,17,34,81,0,0,0,0,186,187,187,174,170,254,238,238,190,238,175,190,0,0,0,0,0,0,0,0,194,205,74,53,50,17,34,81,0,0,0,0,187,187,203,174,187,238,206,188,187,238,191,190,0,0,0,0,0,0,0,0,194,205,65,37,50,202,45,81,0,0,0,0,238,238,239,174,187,238,188,187,187,238,191,190,0,0,0,0,0,0,0,0,194,29,49,37,34,202,45,81,0,0,0,0,187,187,187,174,187,238,190,187,187,238,191,190,0,0,0,0,0,0,0,0,18,18,49,37,35,17,35,81,0,0,0,0,187,187,187,174,187,236,188,203,206,235,191,188,0,0,0,0,0,0,0,0,18,17,49,53,34,17,50,49,0,0,0,0,0,0,0,0,0,0,87,147,119,119,105,70,85,84,119,117,52,50,51,34,177,17,33,47,33,34,34,34,19,18,18,18,0,0,0,0,0,0,87,114,118,87,73,69,212,85,151,103,35,221,35,34,18,31,178,38,50,211,45,34,19,17,18,18,0,0,0,0,0,0,71,218,125,105,73,101,220,69,119,103,35,221,34,18,27,17,34,20,43,34,221,45,36,193,18,29,0,0,0,0,0,0,215,220,117,121,57,103,220,55,151,71,247,223,52,179,31,177,177,181,31,17,220,28,20,193,205,29,0,0,0,0,0,0,103,115,117,215,57,87,83,41,221,71,210,61,68,51,18,251,251,37,50,83,245,85,197,28,205,35,0,0,0,0,0,0,87,148,101,221,63,87,83,201,221,61,17,17,17,31,19,33,23,36,242,33,210,17,23,17,209,34,0,0,0,0,0,0,86,116,86,214,73,102,67,201,221,77,34,34,241,31,19,47,247,33,242,47,34,34,22,17,18,34,0,0,0,0,0,0,101,118,116,118,73,71,82,89,213,71,34,50,243,35,19,47,244,33,17,31,17,17,21,17,34,34,102,119,102,102,69,68,85,118,100,102,73,85,119,119,119,153,170,35,117,71,119,115,121,0,0,0,0,0,0,0,0,0,221,76,68,117,101,68,84,125,116,102,199,221,125,119,119,119,119,34,150,87,105,83,121,0,0,0,0,0,0,0,0,0,223,221,103,69,68,196,220,125,116,87,201,204,76,52,195,204,51,35,117,221,87,116,119,0,0,0,0,0,0,0,0,0,118,119,103,68,52,204,220,125,212,87,167,221,221,102,215,221,205,163,220,221,109,85,119,0,0,0,0,0,0,0,0,0,121,103,68,68,51,172,220,125,212,221,39,68,102,85,70,212,52,195,221,221,119,87,119,0,0,0,0,0,0,0,0,0,34,35,170,76,84,213,108,157,84,221,39,119,151,153,153,170,154,68,85,103,118,55,119,0,0,0,0,0,0,0,0,0,68,196,204,93,117,151,122,149,84,215,37,221,221,157,153,153,153,68,85,103,117,201,119,0,0,0,0,0,0,0,0,0,153,255,255,223,119,153,82,150,100,103,52,249,255,221,121,102,84,67,205,119,116,205,119,0,0,0,0,0,0,0,0,0,153,221,125,103,102,103,98,149,220,87,68,151,221,119,102,85,68,67,204,109,220,205,118,0,0,0,0,0,0,0,0,0,68,85,69,68,85,85,114,244,220,221,70,101,101,214,221,221,151,100,205,89,220,173,86,0,0,0,0,0,0,0,0,0,153,153,153,151,153,119,114,252,124,215,61,119,119,119,214,221,86,116,69,105,220,39,87,0,0,0,0,0,0,0,0,0,51,34,50,67,84,119,115,252,116,103,61,86,102,87,69,100,118,148,69,119,116,39,73,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,51,67,51,34,34,17,18,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,51,68,36,83,34,18,17,50,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,66,115,51,116,34,34,33,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,164,115,114,115,34,18,34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,116,114,179,114,34,18,33,50,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,179,180,115,49,35,18,33,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,115,115,114,50,34,17,33,50,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,115,52,82,35,34,33,17,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,104,213,90,85,180,52,34,18,33,33,19,34,50,52,51,72,0,0,66,101,101,104,152,150,166,138,104,137,0,0,0,0,186,173,182,188,132,34,35,17,65,119,59,51,163,164,183,75,0,0,67,68,101,105,134,136,172,136,136,106,0,0,0,0,220,120,223,52,36,34,34,17,33,187,180,72,180,213,165,52,0,0,50,52,83,101,134,202,169,255,135,136,0,0,0,0,233,88,255,59,31,34,33,241,178,191,52,34,162,180,131,115,0,0,35,68,85,86,150,200,249,135,175,168,0,0,0,0,170,104,255,77,36,34,35,33,177,191,69,84,212,180,117,101,0,0,34,34,68,85,168,166,249,250,169,108,0,0,0,0,217,125,255,52,34,34,34,17,17,191,84,68,84,69,183,37,0,0,68,34,83,133,135,169,252,138,202,202,0,0,0,0,222,121,105,54,68,34,33,17,119,34,179,84,101,87,117,69,0,0,55,67,69,102,102,201,137,255,159,136,0,0,0,0,152,134,102,85,51,18,17,17,34,50,67,85,69,117,87,84,0,0,101,69,68,102,170,168,136,168,172,152,0,0,0,0,0,0,101,101,79,31,0,0,32,18,178,75,7,0,86,100,134,184,136,103,117,134,153,184,169,170,105,153,136,86,86,134,0,0,135,86,79,47,0,0,18,17,33,0,0,0,86,70,136,85,168,134,136,137,169,154,204,156,154,106,106,134,101,86,0,0,136,103,79,47,0,0,242,18,47,0,0,0,186,157,138,157,169,200,138,136,168,233,204,204,152,106,69,132,103,77,0,0,86,86,95,47,0,0,18,17,33,0,0,0,121,110,136,206,202,156,138,137,217,234,172,206,136,134,88,84,86,91,118,102,100,104,84,52,35,52,0,0,0,0,0,0,153,157,142,174,222,204,156,202,201,233,205,206,152,101,181,84,91,91,168,70,102,104,53,52,68,50,0,0,0,0,0,0,185,157,174,158,221,237,205,206,201,236,140,174,136,102,181,83,91,77,137,103,133,86,69,52,34,66,0,0,0,0,0,0,154,158,206,206,221,157,206,205,202,236,142,158,138,88,167,68,91,91,134,168,184,103,85,52,66,68,0,0,0,0,0,0,202,206,206,238,236,236,206,201,204,238,206,174,103,119,181,70,107,92,218,170,204,140,86,83,53,83,0,0,0,0,0,0,204,206,222,222,238,254,222,206,221,237,221,206,153,136,182,86,91,85,169,156,207,159,104,69,245,243,0,0,0,0,0,0,156,238,237,239,222,238,206,222,221,238,156,206,168,120,214,86,107,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,204,238,205,238,237,238,206,236,204,236,204,174,169,117,183,120,86,102,0,0,0,0,0,0,0,0,0,0,0,0,0,0,197,238,222,222,205,254,238,239,238,238,108,141,104,88,216,86,55,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156,222,222,204,204,221,238,205,206,157,154,153,137,136,216,86,86,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,204,201,201,153,206,238,238,238,205,172,170,136,153,134,133,88,102,54,0,0,0,0,0,0,0,0,0,0,0,0,0,0,170,156,204,205,220,238,238,236,205,173,103,154,152,168,136,136,102,52,0,0,0,0,0,0,0,0,0,0,0,0,0,0,170,172,200,216,204,237,221,172,205,108,134,150,139,104,136,136,88,69},
+ {0,0,0,204,204,85,204,204,204,206,236,144,13,0,0,0,0,0,0,0,0,0,0,0,0,0,64,68,68,68,68,68,0,0,0,172,204,85,204,236,204,238,204,137,153,0,0,0,0,0,0,0,0,0,0,0,0,0,68,68,68,0,0,0,0,0,0,204,204,53,206,236,238,206,204,221,221,0,0,0,0,0,0,0,0,0,0,0,0,0,132,102,72,0,0,0,0,0,0,204,58,51,206,238,238,238,204,221,221,0,0,0,0,0,0,0,0,0,0,0,0,0,100,102,70,0,0,0,0,0,0,172,51,131,88,238,204,236,236,0,0,0,136,133,133,88,206,206,136,85,133,85,136,236,100,102,70,0,0,0,0,0,0,204,85,133,85,238,204,238,238,0,0,0,53,136,200,238,235,204,133,88,133,133,83,204,132,102,72,0,0,0,204,204,206,188,60,131,232,204,85,204,172,58,195,202,136,85,204,206,238,236,136,133,133,133,136,236,68,68,68,0,0,0,236,98,198,170,58,51,190,108,120,88,172,58,195,202,88,195,188,206,236,236,136,133,133,53,136,204,0,0,0,0,0,0,236,110,230,17,59,179,17,110,230,88,172,172,163,202,56,206,236,206,188,83,88,88,56,53,229,204,0,0,0,0,0,0,204,238,198,31,92,204,241,108,238,236,172,172,170,202,206,206,190,188,140,85,56,88,236,88,181,203,0,0,0,0,0,0,204,204,206,204,204,204,204,238,204,204,204,172,170,202,238,236,236,188,136,85,206,203,188,206,236,236,0,0,0,0,0,0,204,204,238,236,17,17,206,238,204,206,170,170,172,204,238,236,236,140,136,133,238,204,204,206,238,236,0,0,0,0,0,0,238,206,238,28,159,249,225,238,204,206,172,172,172,170,236,206,236,140,83,85,188,238,206,238,235,204,0,0,0,0,0,0,204,236,204,28,217,157,193,204,236,204,170,170,170,202,206,204,236,92,136,133,238,76,68,68,196,206,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,206,56,133,131,83,238,236,236,206,206,206,206,190,133,235,91,238,140,133,88,88,206,0,0,0,0,0,0,0,0,0,0,238,85,88,53,133,188,238,206,238,235,204,238,204,206,188,236,188,142,88,136,131,204,0,0,0,88,203,159,249,0,0,0,238,190,238,133,227,238,204,204,206,238,236,238,190,238,236,235,238,92,85,88,136,236,0,0,0,181,206,159,249,0,0,0,206,204,203,238,188,206,203,188,206,236,140,200,204,203,238,188,206,203,53,88,133,236,0,0,0,204,190,159,249,0,0,0,238,238,190,236,238,190,206,236,206,188,83,136,238,190,236,238,190,206,133,88,53,203,0,0,0,206,206,255,255,0,0,0,206,204,204,238,204,206,206,190,188,140,85,88,197,204,238,204,88,206,56,53,133,204,0,203,236,204,206,206,236,206,238,0,238,206,204,236,204,136,229,236,188,136,85,136,200,204,236,204,136,229,133,53,136,204,0,188,236,203,140,181,204,188,204,0,238,203,235,204,188,136,133,229,236,142,133,136,83,235,85,53,136,133,133,133,136,236,0,206,236,235,140,227,206,206,206,0,206,236,206,187,136,133,88,236,236,91,85,88,133,88,51,136,133,200,140,133,83,204,0,206,238,236,140,229,190,188,206,0,206,204,238,136,133,88,197,236,204,142,133,88,85,238,136,133,88,197,140,85,136,236,0,188,206,204,140,229,190,204,190,0,188,204,238,53,133,190,203,236,187,236,85,181,85,238,188,140,56,203,236,51,229,204,0,188,136,238,92,200,203,236,190,0,238,238,206,85,232,238,238,204,236,236,236,238,136,206,204,142,136,238,204,236,229,236,0,188,92,206,203,238,236,235,88,0,204,203,236,136,204,188,68,68,68,236,187,204,203,236,238,204,204,238,236,236,236,187,0,204,188,206,188,206,206,140,51,0,204,188,204,236,203,203,132,102,72,204,236,204,188,204,236,203,203,236,236,236,204,236,0,203,206,238,188,190,190,142,200,0,236,238,236,238,206,238,100,102,70,206,238,236,238,236,238,206,206,204,236,204,206,142,0,204,206,238,204,190,206,204,238,0,235,204,188,204,204,206,100,102,70,206,236,235,204,188,204,204,190,206,203,204,206,140,0,238,238,238,238,238,238,236,238,0,204,203,204,188,204,206,132,102,72,206,236,204,203,204,188,204,206,238,88,136,88,229,0,255,255,255,255,255,255,159,249,0,238,204,236,188,204,190,68,68,68,206,235,238,204,236,188,204,206,133,136,85,88,131,0},
+ {0,0,0,0,51,69,100,102,104,51,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,49,69,102,70,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,49,69,102,70,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,19,99,102,70,99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,33,86,86,20,53,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,33,86,86,20,53,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,34,34,37,86,83,51,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33,65,101,70,50,51,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,70,19,34,53,68,102,102,102,53,65,52,86,102,86,0,0,0,117,119,25,152,150,172,204,187,61,0,0,0,0,0,0,51,68,151,89,204,204,219,198,89,69,82,69,83,54,0,0,0,137,135,130,153,106,170,165,201,60,0,0,0,0,0,0,68,52,158,60,31,221,241,214,249,35,19,49,99,35,0,0,0,185,149,146,50,172,169,150,201,203,0,0,0,0,0,0,84,54,68,75,222,238,254,214,53,34,19,50,98,34,0,0,0,154,147,153,153,119,135,153,154,221,0,0,0,0,0,0,100,54,17,70,228,119,62,68,102,66,18,50,100,19,0,0,0,161,148,151,147,133,73,153,203,198,0,0,0,0,0,0,101,85,102,102,230,121,46,51,104,102,36,67,102,19,0,0,0,146,170,147,121,135,148,153,180,205,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,29,205,19,146,170,155,169,84,149,42,186,220,155,204,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,238,35,171,171,170,121,55,153,154,187,221,220,102,237,0,0,0,0,0,0,54,53,175,252,0,0,0,0,0,0,0,0,209,99,156,202,171,154,153,105,202,44,221,222,221,211,0,0,0,0,0,0,70,102,175,253,0,0,0,0,0,0,0,0,154,164,150,102,169,147,153,177,193,213,221,46,237,237,0,0,0,0,0,0,102,69,159,251,0,0,0,0,0,0,0,0,193,170,106,186,153,58,147,169,156,198,212,46,229,102,0,0,0,0,0,0,52,51,255,255,0,0,0,0,0,0,0,0,185,169,150,153,166,151,72,168,171,193,237,227,238,230,0,0,0,0,82,49,51,19,33,33,17,17,0,0,0,0,0,0,198,203,169,153,89,119,152,25,43,28,238,238,230,238,0,0,0,0,52,35,34,18,18,17,18,50,0,0,0,0,0,0,138,102,169,154,68,153,152,168,195,220,29,225,238,238,0,0,0,0,51,99,18,17,17,17,17,17,0,0,0,0,0,0,139,182,148,153,105,73,56,170,27,222,225,238,238,238,0,0,0,0,70,51,33,17,67,20,17,17,0,0,0,0,0,0,107,92,25,203,153,105,151,164,187,44,221,238,94,238,0,0,0,0,238,222,221,171,170,186,185,187,0,0,0,0,0,0,170,182,51,18,154,134,153,57,202,209,108,188,53,226,0,0,0,0,238,222,204,156,170,169,185,204,0,0,0,0,0,0,170,186,172,17,146,73,41,152,203,193,92,92,221,237,0,0,0,0,238,221,220,205,188,186,219,203,0,0,0,0,0,0,185,162,179,155,148,100,153,169,185,195,214,206,212,238,0,0,0,0,238,205,203,186,220,203,205,188,0,0,0,0,0,0,188,185,154,39,147,169,58,154,58,204,221,221,237,227,0,0,0,0,206,205,221,205,222,206,188,203,0,0,0,0,0,0,155,153,89,119,56,169,137,114,161,163,198,205,229,51,0,0,0,0,238,237,221,221,204,187,154,203,0,0,0,0,0,0,148,154,152,120,19,136,153,57,178,162,170,220,229,238,0,0,0,0,222,238,205,204,203,186,154,186,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,175,251,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,102,154,215,222,223,86,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,82,139,254,126,51,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,23,213,255,125,213,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,39,50,205,191,40,122,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,51,50,74,191,166,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,34,145,219,159,99,86,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,39,179,119,237,207,91,129,87,188,238,189,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,135,118,138,205,223,189,139,180,139,183,125,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,120,119,120,215,184,222,155,53,37,98,213,53,0,0,0,0,0,218,38,18,245,204,139,197,53,103,0,0,0,0,0,0,167,126,39,56,115,253,106,51,21,66,195,36,0,0,0,0,0,255,90,19,19,202,189,139,98,86,0,0,0,0,0,0,216,127,242,121,74,136,205,115,19,83,200,21,0,0,0,0,0,203,91,19,100,151,134,93,202,40,0,0,0,0,0,0,202,202,255,253,69,101,255,254,72,134,222,23,0,0,0,0,0,37,86,70,69,141,86,169,253,205,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,56,198,198,123,137,149,185,221,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,99,50,135,154,205,89,67,121,190,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33,195,23,115,217,185,88,184,171,56,18,212,200,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,66,53,53,65,190,186,87,101,85,20,51,101,255,121,0,0,0,0,0,0,108,122,52,17,0,0,0,0,0,0,0,0,113,215,102,85,126,139,71,196,113,53,117,179,235,247,0,0,0,0,0,0,125,221,55,34,0,0,0,0,0,0,0,0,83,152,222,254,254,39,37,65,49,138,199,37,251,207,0,0,0,0,0,0,238,156,37,33,0,0,0,0,0,0,0,0,65,218,255,143,255,91,116,19,17,173,232,53,235,238,0,0,0,0,0,0,88,86,72,19,0,0,0,0,0,0,0,0,133,217,239,255,223,123,149,50,17,50,89,85,214,238,0,0,0,0,195,114,103,21,66,50,17,17,0,0,0,0,0,0,237,221,238,255,189,121,54,17,51,37,19,97,221,255,0,0,0,0,103,53,51,18,34,17,19,83,0,0,0,0,0,0,255,223,252,255,152,187,41,52,133,22,17,33,193,251,0,0,0,0,119,214,18,17,33,18,33,33,0,0,0,0,0,0,255,223,121,251,219,125,70,87,23,19,18,83,231,206,0,0,0,0,157,85,33,17,116,25,17,34,0,0,0,0,0,0,255,205,21,132,213,222,88,136,93,66,21,133,188,156,0,0,0,0,120,118,183,49,101,197,34,84,0,0,0,0,0,0,254,220,87,19,181,204,104,83,18,17,197,251,92,244,0,0,0,0,116,229,158,66,87,136,103,184,0,0,0,0,0,0,186,150,55,33,99,154,52,193,33,34,182,204,131,254,0,0,0,0,152,248,223,252,94,252,139,166,0,0,0,0,0,0,255,50,85,34,135,217,103,52,51,132,252,139,136,251,0,0,0,0,197,254,253,255,190,235,58,121,0,0,0,0,0,0,138,35,228,67,119,170,103,181,115,54,223,249,57,230,0,0,0,0,238,254,223,239,217,237,190,190,0,0,0,0,0,0,119,37,181,86,69,134,19,51,113,183,238,255,106,86,0,0,0,0,237,237,201,207,168,221,236,250,0,0,0,0,0,0,232,104,102,52,37,55,35,81,50,163,253,238,202,104,0,0,0,0,239,238,222,139,204,104,200,251,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,190,85,159,167,235,220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,48,52,4,0,0,0,0,102,102,119,119,0,0,0,0,80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,66,2,0,0,0,0,105,150,119,119,0,0,0,0,85,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,35,3,0,0,0,102,102,102,102,119,119,0,0,0,85,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,50,34,34,34,35,35,35,119,119,119,119,119,119,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,67,163,17,58,52,52,52,0,136,136,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,36,36,34,66,66,66,66,0,136,136,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,50,50,34,35,35,35,35,136,136,136,136,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,67,67,136,52,52,52,52,136,136,136,136,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,36,36,136,66,66,66,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,35,35,35,35,35,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,52,52,52,52,52,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,66,66,66,66,66,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,35,35,35,35,35,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,52,52,52,52,52,0,0,0,0,0,0,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,66,66,66,66,66,66,0,0,0,0,0,0,51,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,35,35,35,35,35,35,35,35,35,35,35,35,0,0,0,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,52,52,52,52,52,52,52,52,52,52,52,0,0,0,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,66,66,66,66,66,66,66,66,66,66,66,66,0,0,0,51,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,35,35,35,35,35,35,35,35,35,35,35,35,0,0,0,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,52,52,52,52,52,52,52,52,52,52,52,67,67,67,51,67,67,67,0,0,0,0,0,0,0,0,0,0,0,0,0,66,66,66,66,66,66,66,66,66,66,66,66,36,36,36,68,36,36,36,0,0,0,0,0,0,0,0,0,0,0,0,0,35,35,35,35,35,35,35,35,35,35,35,35,50,50,50,34,50,50,50,0,0,0,0,0,0,0,0,0,0,0,0,0,52,52,52,52,52,52,52,52,52,52,52,52,67,67,67,51,67,67,67,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+};
+const uint16_t skin_pal[9][16] = {
+ {0x0000,0x05B6,0x0534,0x644A,0x0471,0x4BA7,0x5B6A,0x4346,0x0B4B,0x3B25,0x3AA5,0x1AE8,0x49F5,0x39CA,0x314E,0x2106},
+ {0x0000,0xC618,0xAD55,0xA534,0xA514,0xA514,0x9CD3,0x9CD3,0x94B2,0x9492,0x8C71,0x8C51,0x8C51,0x8430,0x7BCF,0x4A49},
+ {0x0000,0xCEF8,0xC698,0xA6D3,0x9E92,0x7EAE,0x7E4D,0x5E89,0x5E29,0x65EA,0x5D0A,0x45A6,0x1D03,0x546A,0x3C66,0x2AC4},
+ {0x0000,0x5227,0x41E6,0x41C6,0x39A5,0x3985,0x3185,0x3164,0x3124,0x2924,0x2102,0x20C2,0x18C2,0x18C1,0x18A2,0x1061},
+ {0x0000,0xF575,0xED14,0xECF3,0xECB2,0xEC92,0xEC71,0xE471,0xEC30,0xEC0F,0xE40F,0xDC0F,0xE3AE,0xDB8E,0xE34D,0xAAAA},
+ {0x0000,0xCE59,0xFD96,0xB596,0xF575,0xA514,0xCC92,0xB430,0x8410,0x62CB,0x41A4,0x41A4,0x3984,0x3186,0x3143,0x10A2},
+ {0x0000,0xEF5D,0xE71C,0xDEDB,0xD6BA,0xD69A,0xCE59,0xCD94,0xC574,0xC532,0xBCF1,0xB4D0,0xB4AF,0xAC6E,0xA40D,0x72E9},
+ {0x0000,0xFFFF,0xFFDF,0xF79E,0xF79E,0xEF7D,0xEF7D,0xEF5D,0xEF5D,0xE73C,0xE73C,0xE73C,0xE71C,0xDEFB,0xDEFB,0xD6BA},
+ {0x0000,0xFFFF,0xE71C,0xD69A,0xC638,0xE66D,0xC488,0x9386,0xF800,0x62A8,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000},
+};
+const uint8_t cracks[10][32] = {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,128,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,64,0,64,0,192,2,128,3,0,1,0,1,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,64,0,64,0,64,12,192,14,128,3,0,1,0,1,128,1,128,0,0,0,0,0,0,0},{0,0,0,0,0,0,128,0,192,0,64,18,96,30,224,14,128,3,0,1,0,1,192,1,192,0,0,0,0,0,0,0},{0,0,0,0,0,1,128,1,192,34,64,50,112,30,248,14,136,3,0,1,0,1,224,1,224,1,0,1,0,0,0,0},{0,0,0,0,64,3,192,3,192,98,80,114,112,30,248,14,140,3,4,1,32,1,224,1,240,1,16,3,0,2,0,0},{0,0,32,0,96,3,192,3,208,98,80,114,112,30,248,14,140,11,20,1,52,3,224,3,240,1,24,15,8,14,0,0},{0,0,48,0,112,3,204,35,220,102,80,246,112,158,248,14,172,11,52,25,52,19,224,15,242,13,30,15,28,31,16,17},{64,65,120,20,122,55,206,35,222,102,82,246,112,158,248,14,172,11,52,89,53,115,227,47,242,45,30,15,60,63,52,113},{68,85,124,20,122,55,206,35,223,102,83,246,112,158,251,14,175,139,52,217,53,115,227,47,242,237,30,207,60,63,52,113}};
const uint8_t font_bits[96 * 8] = {0,0,0,0,0,0,0,0,1,1,1,1,1,0,1,0,10,10,5,0,0,0,0,0,10,10,31,10,31,10,10,0,4,30,1,14,16,15,4,0,17,9,8,4,2,18,17,0,4,10,4,22,13,9,22,0,2,2,1,0,0,0,0,0,12,2,1,1,1,2,12,0,3,4,8,8,8,4,3,0,0,0,9,6,9,0,0,0,0,4,4,31,4,4,0,0,0,0,0,0,0,1,1,1,0,0,0,31,0,0,0,0,0,0,0,0,0,1,1,0,16,8,8,4,2,2,1,0,14,17,25,21,19,17,14,0,4,6,4,4,4,4,31,0,14,17,16,12,2,17,31,0,14,17,16,12,16,17,14,0,24,20,18,17,31,16,16,0,31,1,15,16,16,17,14,0,12,2,1,15,17,17,14,0,31,17,16,8,4,4,4,0,14,17,17,14,17,17,14,0,14,17,17,30,16,8,6,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,1,8,4,2,1,2,4,8,0,0,0,31,0,0,31,0,0,1,2,4,8,4,2,1,0,14,17,16,8,4,0,4,0,30,33,45,45,61,1,30,0,14,17,31,17,17,17,17,0,15,17,15,17,17,17,15,0,14,17,1,1,1,17,14,0,15,17,17,17,17,17,15,0,31,1,7,1,1,1,31,0,31,1,7,1,1,1,1,0,30,1,25,17,17,17,14,0,17,17,31,17,17,17,17,0,7,2,2,2,2,2,7,0,16,16,16,16,16,17,14,0,17,9,7,9,17,17,17,0,1,1,1,1,1,1,31,0,17,27,21,17,17,17,17,0,17,19,21,25,17,17,17,0,14,17,17,17,17,17,14,0,15,17,15,1,1,1,1,0,14,17,17,17,17,9,22,0,15,17,15,17,17,17,17,0,30,1,14,16,16,17,14,0,31,4,4,4,4,4,4,0,17,17,17,17,17,17,14,0,17,17,17,17,10,10,4,0,17,17,17,17,21,27,17,0,17,10,4,10,17,17,17,0,17,10,4,4,4,4,4,0,31,16,8,4,2,1,31,0,7,1,1,1,1,1,7,0,1,2,2,4,8,8,16,0,7,4,4,4,4,4,7,0,4,10,17,0,0,0,0,0,0,0,0,0,0,0,0,31,1,1,2,0,0,0,0,0,0,0,14,16,30,17,30,0,1,1,13,19,17,17,15,0,0,0,14,17,1,17,14,0,16,16,22,25,17,17,30,0,0,0,14,17,31,1,30,0,12,2,15,2,2,2,2,0,0,0,30,17,17,30,16,15,1,1,13,19,17,17,17,0,1,0,1,1,1,1,1,0,16,0,16,16,16,17,17,14,1,1,9,5,3,5,9,0,1,1,1,1,1,1,2,0,0,0,11,21,21,17,17,0,0,0,15,17,17,17,17,0,0,0,14,17,17,17,14,0,0,0,13,19,17,15,1,1,0,0,22,25,17,30,16,16,0,0,13,19,1,1,1,0,0,0,30,1,14,16,15,0,2,2,7,2,2,2,4,0,0,0,17,17,17,17,30,0,0,0,17,17,17,10,4,0,0,0,17,17,21,21,30,0,0,0,17,10,4,10,17,0,0,0,17,17,17,30,16,15,0,0,31,8,4,2,31,0,12,2,2,1,2,2,12,0,1,1,1,0,1,1,1,0,3,4,4,8,4,4,3,0,38,25,0,0,0,0,0,0,0,0,4,10,17,17,31,0};
const uint8_t font_w[96] = {4,2,5,6,6,6,6,3,5,5,5,6,2,6,2,6,6,6,6,6,6,6,6,6,6,6,2,2,5,6,5,6,7,6,6,6,6,6,6,6,6,4,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,4,6,4,6,6,3,6,6,6,6,6,5,6,6,2,6,5,3,6,6,6,6,6,6,6,4,6,6,6,6,6,6,5,2,5,7,6};
const uint8_t img_rle[18407] = {1,111,155,2,0,96,31,155,96,1,96,31,156,32,96,0,96,18,47,153,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,35,95,1,48,95,37,48,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,48,31,1,80,111,36,16,47,78,65,96,96,17,35,95,1,48,80,111,36,16,39,95,1,48,95,1,48,47,34,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,34,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,34,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,34,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,34,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,34,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,34,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,34,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,34,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,34,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,4,95,1,48,43,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,4,80,63,0,16,43,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,42,48,39,80,63,0,16,43,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,42,49,38,80,63,0,16,43,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,42,50,37,80,63,0,16,43,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,42,51,36,80,63,0,16,43,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,42,52,35,80,63,0,16,43,65,96,96,17,35,48,31,1,80,111,36,16,39,48,31,1,48,31,1,33,62,34,80,63,0,16,43,65,96,96,17,35,95,1,48,80,111,36,16,39,95,1,48,95,1,48,33,63,0,33,80,63,0,16,43,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,33,62,34,80,63,0,16,43,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,42,52,35,80,63,0,16,43,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,42,51,36,80,63,0,16,43,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,42,50,37,80,63,0,16,43,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,42,49,38,80,63,0,16,43,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,42,48,39,80,63,0,16,43,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,4,80,63,0,16,43,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,4,80,63,0,16,43,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,4,48,31,1,43,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,34,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,34,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,34,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,34,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,34,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,34,65,96,96,17,35,80,63,0,16,80,111,36,16,39,80,63,0,16,80,63,0,16,47,34,65,96,96,17,35,48,31,1,80,111,36,16,39,48,31,1,48,31,1,47,34,65,96,96,17,35,95,1,48,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,80,63,0,16,80,111,36,16,47,78,65,96,96,17,35,48,31,1,48,31,37,47,78,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,153,66,96,0,96,32,79,156,96,1,96,79,155,96,0,2,111,155,1,1,111,155,2,0,96,31,155,96,1,96,31,156,32,96,0,96,18,47,153,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,10,95,1,48,95,1,48,95,1,48,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,20,95,9,48,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,20,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,20,80,63,8,16,47,12,65,96,96,17,47,10,48,31,1,48,31,1,48,31,1,47,20,80,63,8,16,47,12,65,96,96,17,47,10,95,1,48,95,1,48,95,1,48,47,20,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,5,48,45,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,5,49,44,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,5,50,43,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,5,51,42,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,5,52,41,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,5,53,40,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,38,63,5,39,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,38,63,6,38,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,38,63,5,39,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,5,53,40,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,5,52,41,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,5,51,42,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,5,50,43,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,5,49,44,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,5,48,45,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,20,80,63,8,16,47,12,65,96,96,17,47,10,48,31,1,48,31,1,48,31,1,47,20,80,63,8,16,47,12,65,96,96,17,47,10,95,1,48,95,1,48,95,1,48,47,20,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,20,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,20,80,63,8,16,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,20,48,31,9,47,12,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,80,63,0,16,80,63,0,16,80,63,0,16,47,74,65,96,96,17,47,10,48,31,1,48,31,1,48,31,1,47,74,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,153,66,96,0,96,32,79,156,96,1,96,79,155,96,0,2,111,155,1,1,111,155,2,0,96,31,155,96,1,96,31,156,32,96,0,96,18,47,153,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,36,95,1,48,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,22,95,9,48,47,20,65,96,96,17,47,36,80,63,0,16,47,22,80,63,8,16,47,20,65,96,96,17,47,36,80,63,0,16,47,22,80,63,8,16,47,20,65,96,96,17,47,36,48,31,1,47,22,80,63,8,16,47,20,65,96,96,17,47,92,80,63,8,16,47,20,65,96,96,17,47,75,48,47,0,80,63,8,16,47,20,65,96,96,17,47,75,49,46,80,63,8,16,47,20,65,96,96,17,47,39,48,40,48,47,9,50,45,80,63,8,16,47,20,65,96,96,17,47,39,48,40,48,47,9,51,44,80,63,8,16,47,20,65,96,96,17,47,40,48,34,48,34,48,47,10,52,43,80,63,8,16,47,20,65,96,96,17,47,40,48,34,48,34,48,47,10,53,42,80,63,8,16,47,20,65,96,96,17,47,39,49,35,48,33,49,42,63,5,41,80,63,8,16,47,20,65,96,96,17,47,39,49,35,48,33,49,42,63,6,40,80,63,8,16,47,20,65,96,96,17,47,38,50,34,49,33,50,41,63,5,41,80,63,8,16,47,20,65,96,96,17,47,38,49,35,49,34,49,47,8,53,42,80,63,8,16,47,20,65,96,96,17,47,38,49,34,50,34,49,47,8,52,43,80,63,8,16,47,20,65,96,96,17,47,38,50,33,49,34,50,47,8,51,44,80,63,8,16,47,20,65,96,96,17,47,39,49,33,49,34,49,47,9,50,45,80,63,8,16,47,20,65,96,96,17,47,39,49,33,50,33,49,47,9,49,46,80,63,8,16,47,20,65,96,96,17,47,38,50,33,50,33,50,47,8,48,47,0,80,63,8,16,47,20,65,96,96,17,47,92,80,63,8,16,47,20,65,96,96,17,47,92,80,63,8,16,47,20,65,96,96,17,47,36,95,1,48,47,22,80,63,8,16,47,20,65,96,96,17,47,36,80,63,0,16,47,22,80,63,8,16,47,20,65,96,96,17,47,36,80,63,0,16,47,22,80,63,8,16,47,20,65,96,96,17,47,36,80,63,0,16,47,22,48,31,9,47,20,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,80,63,0,16,47,84,65,96,96,17,47,36,48,31,1,47,84,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,153,66,96,0,96,32,79,156,96,1,96,79,155,96,0,2,111,155,1,1,111,155,2,0,96,31,155,96,1,96,31,156,32,96,0,96,18,47,153,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,35,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,95,1,48,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,80,63,0,16,35,65,96,96,17,35,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,48,31,1,35,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,154,65,96,96,17,47,153,66,96,0,96,32,79,156,96,1,96,79,155,96,0,2,111,155,1};
diff --git a/games/numblocks/src/data.h b/games/numblocks/src/data.h
index 10077cd1..0a33ceba 100644
--- a/games/numblocks/src/data.h
+++ b/games/numblocks/src/data.h
@@ -283,6 +283,10 @@ extern const uint16_t group_planks[]; /* ends with 0xFFFF */
extern const uint16_t group_wool[]; /* ends with 0xFFFF */
extern const uint16_t group_log[]; /* ends with 0xFFFF */
extern const uint16_t group_sapling[]; /* ends with 0xFFFF */
+extern const uint8_t skin_px[][1024]; /* mob skins, 64 x 32 */
+extern const uint16_t skin_pal[][16];
+enum { SKIN_ZOMBIE, SKIN_SKELETON, SKIN_CREEPER, SKIN_SPIDER, SKIN_PIG, SKIN_COW, SKIN_SHEEP, SKIN_SHEEP_FUR, SKIN_CHICKEN };
+extern const uint8_t cracks[10][32]; /* destroy stages, 1 bit a texel */
extern const uint8_t font_bits[96 * 8], font_w[96]; /* characters 32-127 */
extern const uint8_t img_rle[], img_w[], img_h[];
extern const uint32_t img_rows[];
diff --git a/games/numblocks/src/entity.c b/games/numblocks/src/entity.c
index 4079540c..a30c5a37 100644
--- a/games/numblocks/src/entity.c
+++ b/games/numblocks/src/entity.c
@@ -1,4 +1,4 @@
-/* Entities: dropped items for now (EntityItem), mobs to come.
+/* Entities: dropped items (EntityItem) here, mobs and arrows in mob.c.
*
* An item falls (0.04 a tick, drag 0.98), slides (0.6 x 0.98 on the ground),
* bounces a little, joins the same items near it, can be picked up after 10
@@ -108,11 +108,17 @@ void ents_tick(void) {
e->px = e->x, e->py = e->y, e->pz = e->z;
e->age++;
/* far outside the loaded blocks: gone */
- if (!world_loaded((int)floorf(e->x), 64, (int)floorf(e->z))) {
+ if (!world_loaded((int)floorf(e->x), vc_y0, (int)floorf(e->z))) {
e->type = E_NONE;
continue;
}
if (e->type == E_ITEM) item_tick(e);
+ else mob_tick(e);
if (e->y < -64) e->type = E_NONE;
}
+ static int spawn_wait;
+ if (++spawn_wait >= 20) {
+ spawn_wait = 0;
+ mobs_spawn();
+ }
}
diff --git a/games/numblocks/src/gen.c b/games/numblocks/src/gen.c
index 4de4875b..04b80377 100644
--- a/games/numblocks/src/gen.c
+++ b/games/numblocks/src/gen.c
@@ -148,41 +148,227 @@ static void jr_skip(JRand *r, unsigned n) {
/* MathHelper */
/* ======================================================================== */
-/* sin of table index i (0..65535): (float)Math.sin(i * 2pi / 65536) */
+/* sin of table index i (0..65535): (float)Math.sin(i * 2pi / 65536), as MathHelper's table.
+ * A float kernel (fdlibm's sinf/cosf kernels) on the first quadrant gets within an ulp; a
+ * 2-bit-per-entry correction table (generated on a host from the exact values) makes it exact.
+ * The kernels must not be contracted into FMAs, or the corrections would not apply. */
+#if defined(__GNUC__) && !defined(__clang__)
+#define NO_CONTRACT __attribute__((optimize("fp-contract=off")))
+#else
+#define NO_CONTRACT
+#endif
+/* MathHelper sin table corrections (generated by tests/gen/t_sintab2.c): 2 bits per
+ * first-quadrant index, value = correction in ulps + 1, 3 = see SIN_EXC */
+static const uint8_t SIN_CORR[4097] = {
+85,20,84,69,80,84,21,84,21,21,68,84,1,20,96,21,85,68,21,84,84,84,84,21,
+69,65,84,85,85,69,65,65,85,65,69,20,21,69,21,81,68,21,85,65,84,5,69,65,
+85,81,81,20,5,85,85,21,84,5,22,68,21,84,1,20,1,21,65,21,81,5,84,16,
+21,64,85,20,0,85,129,85,81,165,85,21,4,86,21,69,84,85,68,64,85,69,1,100,
+69,85,65,69,21,5,85,69,4,69,85,5,16,85,21,5,85,21,5,16,85,21,4,101,
+85,1,4,5,20,1,80,69,65,68,21,81,5,85,85,20,80,85,20,1,84,85,1,65,
+85,0,17,84,85,5,80,85,85,1,21,81,65,80,21,21,0,85,5,150,85,85,69,17,
+20,84,153,21,80,17,5,0,81,86,85,85,85,80,0,160,89,85,84,65,68,0,84,85,
+21,85,20,64,16,164,86,21,85,20,5,0,101,85,21,69,21,68,0,84,85,85,68,0,
+16,80,85,85,85,17,1,64,0,106,85,85,69,84,21,16,85,85,85,85,1,16,65,85,
+85,64,81,0,1,148,85,85,17,1,16,1,64,85,21,81,21,17,64,84,85,69,21,21,
+0,17,144,85,80,85,21,16,64,80,85,85,21,1,0,0,84,85,85,1,69,65,0,84,
+85,80,20,20,1,0,84,85,85,4,1,1,0,85,21,85,68,5,1,0,85,17,21,81,
+21,1,4,85,84,69,84,1,65,64,85,81,84,64,86,85,89,85,21,85,85,17,85,85,
+68,80,84,84,89,85,85,85,85,21,81,85,81,20,0,4,0,170,85,85,85,85,85,65,
+69,20,0,68,4,0,65,149,101,85,69,85,81,85,21,17,84,65,4,85,64,101,85,85,
+85,85,69,1,84,20,84,16,65,21,80,101,85,85,85,69,21,4,85,1,80,4,85,0,
+84,86,85,85,85,85,85,17,85,5,65,85,16,4,100,101,85,85,85,21,81,64,17,1,
+16,16,64,16,105,86,85,85,85,85,81,65,65,68,85,64,0,64,149,85,85,85,17,85,
+21,5,64,81,64,17,5,65,85,101,85,85,68,85,69,1,80,81,21,17,0,80,85,85,
+85,85,85,21,81,21,20,0,1,85,16,164,85,85,85,85,85,81,85,20,0,81,0,17,
+0,148,85,81,85,69,81,17,1,16,1,64,16,4,1,85,85,85,85,85,85,80,4,0,
+65,21,16,64,0,85,85,85,85,85,85,84,20,64,4,64,4,0,80,89,85,85,85,21,
+21,85,84,17,1,69,0,1,100,85,85,21,69,85,21,65,69,20,4,84,1,0,80,85,
+85,85,21,80,20,20,1,16,5,1,85,64,84,85,21,85,81,1,68,0,17,0,65,5,
+0,0,85,85,85,20,69,21,20,85,17,4,0,64,16,0,85,21,21,81,21,5,68,0,
+21,64,4,16,68,64,85,85,85,85,21,21,21,20,1,68,64,0,64,80,85,85,20,80,
+1,69,85,20,89,169,149,101,149,85,85,85,85,85,85,85,81,69,17,21,64,17,81,85,
+16,81,0,5,64,1,88,102,149,85,85,101,85,85,85,85,84,85,85,17,69,21,84,20,
+0,68,4,20,16,65,85,65,4,64,101,86,85,89,85,85,85,85,69,85,85,85,69,69,
+85,81,85,0,20,69,85,16,81,65,1,80,64,96,86,90,85,85,85,85,85,69,81,85,
+85,85,85,21,81,84,80,21,0,20,65,85,16,1,0,1,1,84,102,165,86,85,85,85,
+21,85,85,21,64,21,5,80,68,1,20,17,0,4,4,0,1,1,64,64,0,101,101,85,
+149,85,101,85,85,85,85,65,69,84,80,17,85,21,81,0,4,4,0,17,5,4,17,0,
+148,101,101,85,85,85,85,85,85,85,85,81,1,85,21,64,81,84,81,20,64,17,5,20,
+16,0,68,64,85,102,85,85,85,85,85,85,21,85,85,17,85,81,81,21,21,85,69,84,
+80,68,0,4,4,64,64,0,89,89,85,89,85,85,85,21,85,65,85,5,80,85,64,17,
+85,69,20,80,68,1,69,80,5,65,64,96,89,85,85,85,85,85,85,69,81,20,69,21,
+85,69,84,21,81,0,17,5,69,4,64,4,21,0,80,84,101,85,85,85,85,85,85,85,
+85,81,85,85,84,20,21,20,81,85,68,85,17,5,5,4,64,4,0,85,85,85,86,85,
+85,85,84,21,85,85,85,5,20,65,69,69,21,4,85,16,84,65,80,65,4,0,144,85,
+85,85,85,85,85,85,85,5,65,69,85,68,85,81,84,16,21,5,4,16,81,21,16,0,
+1,0,85,153,85,85,85,85,21,69,81,84,85,20,69,81,64,17,0,69,65,65,1,68,
+80,65,64,64,16,0,85,85,85,86,85,85,85,69,85,20,21,85,84,0,69,1,69,1,
+68,84,16,1,4,20,4,20,5,68,85,85,85,85,85,85,85,85,85,21,80,84,84,84,
+84,85,85,20,80,20,80,20,80,4,64,4,64,84,85,89,85,81,21,85,85,69,65,84,
+84,81,69,21,20,65,64,80,65,80,65,0,16,1,4,80,16,85,86,85,85,65,85,85,
+85,85,81,85,85,85,20,80,4,64,20,16,65,65,80,65,0,16,84,16,148,85,85,85,
+85,85,85,21,80,84,85,81,81,81,17,85,69,1,17,21,4,5,17,64,16,16,1,0,
+84,85,85,85,85,85,85,69,85,69,69,84,69,80,20,20,68,85,68,5,65,69,4,4,
+84,16,20,64,85,85,85,85,85,85,85,1,85,85,68,21,69,69,84,65,1,5,85,4,
+0,1,0,0,16,84,0,64,85,85,85,69,85,84,0,85,80,20,20,5,84,0,5,21,
+81,5,5,68,0,4,21,16,16,1,0,84,85,85,85,85,85,85,69,81,80,5,80,1,
+68,64,81,85,80,69,0,68,21,4,16,0,16,0,4,85,85,85,85,84,85,20,80,17,
+84,64,81,21,1,20,85,68,38,18,17,22,34,81,17,17,18,18,17,17,81,17,17,17,
+17,17,17,209,209,29,17,17,93,72,149,137,152,84,132,68,84,69,69,68,68,68,69,68,
+68,68,4,68,68,68,68,68,68,7,67,48,87,101,21,37,101,85,22,18,17,81,17,81,
+17,81,85,21,81,85,81,21,69,21,17,21,20,85,81,21,85,85,85,85,85,69,85,85,
+68,84,68,69,68,85,20,85,84,68,68,69,84,68,68,65,21,5,64,84,97,85,18,97,
+85,85,21,86,82,21,85,85,81,81,80,85,81,21,17,21,81,17,21,81,17,81,21,69,
+84,68,69,84,88,84,69,85,73,68,85,85,68,85,69,68,69,85,85,84,65,68,68,68,
+68,4,68,85,21,81,85,97,85,17,86,21,85,17,81,17,85,85,85,81,21,17,21,81,
+16,84,21,85,65,1,81,85,85,68,85,73,85,85,84,68,84,69,85,84,85,85,85,85,
+85,69,85,81,84,69,85,0,84,68,85,82,85,85,85,85,85,82,21,17,21,85,85,17,
+81,85,17,21,16,85,81,21,85,81,21,21,17,80,69,69,84,68,85,85,85,68,84,85,
+69,69,84,68,69,84,68,85,5,64,85,69,84,68,5,84,4,69,85,85,85,82,85,81,
+85,81,85,85,85,85,85,17,81,85,21,21,81,17,85,21,16,69,21,81,1,89,69,85,
+84,73,68,85,73,84,68,69,88,85,68,84,69,85,84,69,68,85,20,69,85,84,84,84,
+68,85,85,21,85,21,81,85,17,21,81,17,85,21,81,17,21,81,85,21,21,81,69,1,
+81,21,85,16,145,149,84,84,85,89,85,69,84,149,84,69,68,85,85,69,85,68,69,68,
+64,69,5,68,68,69,68,5,37,85,85,37,21,86,85,21,38,85,85,85,85,21,21,81,
+85,17,21,81,81,1,81,17,17,85,65,5,85,152,148,85,85,85,69,84,132,85,73,84,
+68,85,85,84,85,0,84,68,68,85,84,69,68,64,68,80,85,81,37,21,85,21,85,21,
+85,21,17,85,85,21,21,85,81,81,85,80,81,81,21,21,5,84,21,85,84,84,69,68,
+85,84,85,84,84,85,85,85,85,84,145,69,65,69,69,69,80,21,4,69,69,84,68,102,
+97,81,85,85,81,86,85,85,85,17,86,37,81,81,85,81,81,85,81,17,17,81,65,17,
+85,81,85,85,148,84,69,84,85,85,69,84,84,68,85,73,84,85,85,85,85,85,85,81,
+84,84,69,68,69,68,84,85,37,81,33,101,85,21,21,37,85,85,21,81,81,17,21,21,
+17,81,17,21,5,65,21,85,1,21,85,69,85,84,84,133,73,85,68,69,88,69,85,85,
+85,85,85,85,85,68,68,20,69,69,81,84,20,69,85,21,38,85,81,82,21,81,17,85,
+81,81,21,21,20,85,84,5,65,85,85,1,16,81,21,17,0,69,84,69,133,149,68,69,
+84,85,84,69,85,21,69,20,85,84,68,69,69,84,85,81,68,1,69,68,4,85,85,85,
+18,85,21,97,21,85,85,81,21,81,21,17,17,85,81,81,85,69,85,85,17,17,1,16,
+132,149,84,84,84,85,69,85,85,85,85,69,84,85,84,84,69,69,84,69,68,68,85,68,
+4,20,5,68,20,38,85,85,85,85,37,85,85,85,21,85,81,81,21,81,85,17,85,17,
+17,81,21,81,17,17,21,85,153,105,170,154,153,153,153,85,149,149,165,89,89,153,85,85,
+89,149,89,149,85,85,149,165,148,85,85,85,86,102,169,101,86,102,86,102,102,85,89,86,
+86,101,86,85,85,102,85,101,86,82,165,81,85,85,102,85,102,154,150,149,149,89,153,153,
+154,85,85,105,88,153,85,149,149,89,149,149,149,85,85,85,149,88,84,101,85,89,86,86,
+105,85,22,86,86,166,85,85,85,85,101,22,149,101,85,85,85,101,21,85,85,85,169,105,
+150,105,89,89,153,153,149,85,101,85,149,89,149,152,153,153,85,149,85,85,90,85,85,85,
+85,85,101,85,102,86,154,85,101,102,90,22,86,102,86,102,85,85,85,101,85,85,85,101,
+105,85,85,22,85,85,102,154,150,89,101,85,149,89,149,89,105,89,106,137,85,153,85,85,
+89,89,133,85,85,84,149,149,68,85,102,101,101,102,146,165,86,105,101,86,86,102,85,85,
+86,101,85,85,85,85,101,21,85,85,97,101,101,101,101,149,149,153,166,85,153,85,153,85,
+85,85,101,85,85,149,105,165,89,85,85,85,85,85,69,153,85,153,86,101,105,154,101,90,
+101,101,102,102,102,101,101,85,102,85,102,85,25,86,102,86,86,85,85,97,86,165,150,153,
+89,85,149,89,85,85,89,85,149,149,149,148,85,85,89,149,85,89,85,85,153,84,85,85,
+104,86,85,101,86,85,85,101,101,102,101,85,85,85,102,85,85,166,85,102,85,85,102,81,
+85,85,17,85,86,149,153,85,89,153,150,85,85,89,105,86,85,85,85,149,149,89,85,149,
+89,85,149,85,149,85,84,84,90,102,102,105,85,86,102,89,85,101,85,102,85,102,85,102,
+85,86,85,85,102,85,85,102,81,21,86,101,85,153,85,85,154,85,85,153,85,153,85,85,
+85,85,154,85,154,85,153,85,153,85,152,85,152,84,152,100,169,101,165,102,102,102,102,102,
+102,102,102,102,101,101,101,101,105,85,85,85,85,85,85,86,86,101,85,153,149,85,153,153,
+85,85,89,153,85,100,85,85,85,85,72,89,89,89,85,85,85,85,85,85,73,85,85,85,
+86,150,102,102,101,101,101,101,102,86,82,85,85,101,90,85,101,86,101,86,101,86,85,101,
+18,85,89,165,85,153,86,153,85,105,149,85,85,89,153,153,153,149,89,89,85,85,149,101,
+85,85,85,85,133,85,85,101,86,85,85,101,85,101,86,150,85,85,85,85,85,86,102,85,
+85,102,85,85,85,85,85,86,86,150,150,89,85,165,150,149,149,85,85,85,153,85,153,85,
+85,154,149,149,148,85,89,73,85,85,85,85,149,85,101,85,101,90,21,101,101,86,86,101,
+85,89,102,85,85,102,85,85,85,85,101,85,21,21,21,86,85,85,153,85,89,153,153,149,
+149,89,85,85,85,85,85,149,133,85,85,85,85,85,85,89,149,149,85,89,85,85,85,85,
+101,86,85,85,85,169,101,101,85,85,102,85,85,86,85,86,86,21,85,21,85,85,81,85,
+85,85,85,85,85,85,85,89,85,133,85,85,85,153,85,85,89,89,85,85,149,73,85,148,
+149,85,69,85,101,101,85,86,85,102,101,89,101,150,149,21,101,86,86,102,85,85,86,37,
+81,21,101,85,85,82,85,149,85,85,90,89,85,150,89,85,85,85,101,153,85,89,153,153,
+85,84,133,85,85,69,84,149,85,89,149,85,85,85,85,85,85,85,101,85,86,21,85,85,
+85,89,150,86,89,85,105,86,86,101,85,101,149,85,85,149,86,85,101,105,85,85,86,85,
+85,85,149,21,85,85,85,149,149,149,89,101,89,85,101,85,85,86,101,85,86,101,85,89,
+85,89,85,85,85,85,85,85,81,85,85,86,89,85,85,149,85,90,149,86,85,89,85,85,
+85,85,85,149,86,85,85,85,89,85,85,85,101,85,101,89,89,86,85,85,106,89,85,85,
+149,149,85,85,85,86,85,85,149,85,85,85,85,85,85,85,149,85,85,149,85,85,85,150,
+149,101,85,85,85,85,149,101,85,85,85,85,85,149,85,85,85,81,81,85,85,85,85,85,
+101,85,149,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,80,85,85,105,
+86,85,85,89,85,149,85,89,165,85,105,85,106,85,85,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,85,149,165,86,85,85,85,101,85,149,85,85,85,85,85,85,101,85,89,
+85,85,85,85,85,85,85,85,86,86,85,86,85,86,85,86,85,89,85,85,85,85,85,85,
+85,85,85,85,85,85,85,81,85,85,149,89,85,85,85,101,85,85,85,85,86,85,85,85,
+85,86,89,89,85,85,85,85,85,85,85,85,69,85,85,85,85,89,85,85,85,85,85,85,
+85,85,86,85,86,89,85,85,85,85,85,85,85,85,85,85,85,85,85,101,86,85,85,85,
+85,86,149,149,85,105,85,85,85,149,85,85,85,85,85,85,89,85,85,85,86,85,86,85,
+85,101,85,150,86,85,89,85,85,85,85,85,85,85,85,89,85,85,85,85,85,85,85,85,
+85,149,85,85,85,101,85,85,153,85,101,149,85,85,85,85,85,85,85,85,85,85,85,85,
+84,85,85,85,85,89,85,85,85,86,86,85,101,85,86,85,85,85,85,86,85,85,149,85,
+85,85,85,85,85,85,85,85,149,85,85,85,86,85,86,101,105,85,85,85,85,85,85,101,
+89,85,85,85,85,85,85,85,85,85,85,85,85,149,101,86,85,85,85,85,89,101,85,85,
+85,85,85,86,149,85,89,85,85,85,85,85,85,85,85,85,85,85,86,85,89,85,85,85,
+85,101,85,85,85,85,85,149,85,85,85,85,85,85,85,85,85,85,85,85,85,149,89,85,
+85,85,85,85,86,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
+150,85,85,85,85,85,85,85,85,85,89,85,85,89,85,85,85,85,69,85,85,85,85,85,
+85,85,85,149,85,89,86,101,105,149,85,149,85,85,85,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,84,101,89,149,85,86,85,149,89,85,101,101,85,89,85,85,86,85,149,
+85,85,85,85,85,85,85,85,85,85,85,85,85,149,149,85,85,85,149,85,85,149,85,85,
+85,85,85,85,85,85,85,89,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,85,85,101,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
+85,85,85,85,149,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,85,85,149,85,101,85,85,85,85,85,85,85,85,85,85,85,85,101,85,
+85,85,85,85,85,85,85,85,85,85,101,85,85,85,149,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,85,85,85,85,85,85,101,85,85,89,85,85,85,85,85,85,85,85,85,
+85,101,85,85,85,89,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,101,85,
+85,85,85,85,85,85,89,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,85,85,81,85,85,85,85,101,85,85,85,85,85,85,85,85,85,85,85,
+101,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,149,85,85,85,
+85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,149,85,85,85,85,
+85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,69,85,85,85,85,85,
+85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,81,85,
+85,85,149,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,85,85,89,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
+85,89,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,85,85,85,85,85,85,85,85,85,101,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,
+85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,1,};
+/* entries whose correction is beyond one ulp: index, exact float bits */
+static const u32 SIN_EXC[][2] = {{5295, 0x3ef8e592u},{5299, 0x3ef9117eu},{5301, 0x3ef92773u},{5313, 0x3ef9ab25u},{5412, 0x3efde662u},{5416, 0x3efe1207u},{5422, 0x3efe537au},{5424, 0x3efe694au},{65536, 0}};
+
+NO_CONTRACT static float sin_quadrant(u32 r) { /* r in [0, 16384] */
+ if (r <= 8192) {
+ float x = (float)r * 9.58737992428526e-05f;
+ float z = x * x, v = z * x;
+ float rr = 8.3333337680e-03f + z * (-1.9841270114e-04f + z * 2.7183114939e-06f);
+ return x + v * (-1.6666667163e-01f + z * rr);
+ } else {
+ float x = (float)(16384 - r) * 9.58737992428526e-05f;
+ float z = x * x;
+ float rr = z * (4.1666667908e-02f + z * (-1.3888889225e-03f + z * (2.4801587642e-05f + z * -2.7557314297e-07f)));
+ float hz = 0.5f * z, w = 1.0f - hz;
+ return w + (((1.0f - w) - hz) + z * rr);
+ }
+}
+
static float sin_index(u32 i) {
i &= 65535;
- if ((i & 16383) == 0) {
- static const float exact[4] = {0.0f, 1.0f, 1.2246467991473532e-16f, -1.0f};
- return exact[i >> 14];
- }
- u32 q = i >> 13; /* octant */
- i32 r = (i32)(i & 8191);
- int usecos;
- float sign = 1.0f;
- /* angle in [0, 2pi): octant 0: sin(r), 1: cos(8192-r), 2: cos(r), 3: sin(8192-r), 4..7 negated */
- if (q >= 4) {
- sign = -1.0f;
- q -= 4;
- }
- if (q == 0) {
- usecos = 0;
- } else if (q == 1) {
- usecos = 1;
- r = 8192 - r;
- } else if (q == 2) {
- usecos = 1;
- } else {
- usecos = 0;
- r = 8192 - r;
+ if (i == 32768) return 1.2246467991473532e-16f;
+ u32 q = i >> 14, r = i & 16383;
+ if (q & 1) r = 16384 - r;
+ float v = sin_quadrant(r);
+ int d = (int)((SIN_CORR[r >> 2] >> ((r & 3) * 2)) & 3) - 1;
+ if (d == 2) {
+ for (int k = 0;; k++)
+ if (SIN_EXC[k][0] == r || SIN_EXC[k][0] == 65536) {
+ memcpy(&v, &SIN_EXC[k][1], 4);
+ break;
+ }
+ } else if (d) {
+ u32 b;
+ memcpy(&b, &v, 4);
+ b = (u32)((i32)b + d);
+ memcpy(&v, &b, 4);
}
- float x = (float)r * 9.58737992428526e-05f; /* 2pi/65536 */
- float x2 = x * x;
- float v;
- if (!usecos)
- v = x + x * x2 * (-1.6666654611e-1f + x2 * (8.3321608736e-3f + x2 * (-1.9515295891e-4f)));
- else
- v = 1.0f - 0.5f * x2 + x2 * x2 * (4.166664568298827e-2f + x2 * (-1.388731625493765e-3f + x2 * 2.443315711809948e-5f));
- return sign * v;
+ return (q & 2) ? -v : v;
}
static inline float mh_sin(float f) { return sin_index((u32)(i32)(f * 10430.378f)); }
@@ -1305,9 +1491,32 @@ typedef struct {
uint8_t mesa_ready;
} TerrainScratch;
+typedef struct {
+ int x, y, z; /* lake box origin (world) */
+ uint8_t liquid;
+ uint8_t shape[256]; /* 16x16x8 bits: index (x*16+z)*8+y */
+} LakeRec;
+
+typedef struct {
+ int px, pz, ox, oz; /* populated chunk, frame origin (frame = 32x32 columns) */
+ uint8_t top[1024], tb[1024]; /* highest non-plant block of each frame column, and the block */
+ uint8_t pl[1024]; /* plant-like block right above top (0 = none) */
+ int nlake;
+ LakeRec lake[2];
+ /* cave query mask active for reads */
+ int qon, qx0, qy0, qz0, qx1, qy1, qz1;
+} View;
+
+typedef struct {
+ View v;
+ uint8_t qmask[2048];
+ i32 lay[640];
+} PopScratch;
+
static union {
TerrainScratch t;
i32 lay[LAY_INTS];
+ PopScratch p;
} U;
/* ======================================================================== */
@@ -1792,14 +2001,14 @@ enum {
BF_LOG = 16,
BF_PLANT = 32, /* REPLACEABLE_PLANT or PLANT material (flowers, grass, saplings...) */
BF_CUBE = 64, /* Block.o(): opaque full cube (leaves included on the server) */
- BF_LIQUID = 128
+ BF_LIQUID = 128,
+ BF_RPLANT = 256 /* Material.REPLACEABLE_PLANT (tall grass, ferns, double plants, vines, dead bush) */
};
-static uint8_t bflags[256];
+static uint16_t bflags[256];
static void bflags_init(void) {
for (int i = 0; i < 256; i++) bflags[i] = BF_OPAQUE | BF_SOLID | BF_BUILD | BF_CUBE;
- static const uint8_t air[] = {B_AIR};
- bflags[air[0]] = 0;
+ bflags[B_AIR] = 0;
bflags[B_WATER] = bflags[B_FLOWING_WATER] = BF_OPAQUE | BF_LIQUID;
bflags[B_LAVA] = bflags[B_FLOWING_LAVA] = BF_LIQUID;
static const uint8_t leaves[] = {B_LEAVES_OAK, B_LEAVES_SPRUCE, B_LEAVES_BIRCH, B_LEAVES_JUNGLE, B_LEAVES_ACACIA,
@@ -1821,6 +2030,11 @@ static void bflags_init(void) {
B_LARGE_FERN_UPPER, B_ROSE_BUSH_LOWER, B_ROSE_BUSH_UPPER, B_PEONY_LOWER,
B_PEONY_UPPER};
for (unsigned i = 0; i < sizeof plants; i++) bflags[plants[i]] = BF_PLANT;
+ static const uint8_t rplants[] = {B_DEAD_SHRUB, B_TALL_GRASS, B_FERN, B_DEAD_BUSH, B_VINE, B_SUNFLOWER_LOWER,
+ B_SUNFLOWER_UPPER, B_LILAC_LOWER, B_LILAC_UPPER, B_DOUBLE_GRASS_LOWER,
+ B_DOUBLE_GRASS_UPPER, B_LARGE_FERN_LOWER, B_LARGE_FERN_UPPER, B_ROSE_BUSH_LOWER,
+ B_ROSE_BUSH_UPPER, B_PEONY_LOWER, B_PEONY_UPPER};
+ for (unsigned i = 0; i < sizeof rplants; i++) bflags[rplants[i]] |= BF_RPLANT;
bflags[B_SNOW_LAYER] = 0; /* not solid, opacity 0 */
bflags[B_ICE] = BF_OPAQUE | BF_SOLID | BF_BUILD;
bflags[B_PACKED_ICE] = BF_OPAQUE | BF_SOLID | BF_BUILD | BF_CUBE;
@@ -1842,6 +2056,7 @@ static void bflags_init(void) {
#define IS_OPAQUE(b) (bflags[b] & BF_OPAQUE)
#define IS_CUBE(b) (bflags[b] & BF_CUBE)
#define IS_PLANT(b) (bflags[b] & BF_PLANT)
+#define IS_RPLANT(b) (bflags[b] & BF_RPLANT)
#define IS_WATER(b) ((b) == B_WATER || (b) == B_FLOWING_WATER)
#define IS_DIRTISH(b) ((b) == B_DIRT || (b) == B_COARSE_DIRT || (b) == B_PODZOL)
#define IS_CLAY(b) ((b) == B_HARDENED_CLAY || ((b) >= B_STAINED_CLAY_WHITE && (b) <= B_STAINED_CLAY_BLACK))
@@ -1877,3 +2092,608 @@ static uint8_t sum_block(const ColSum *s, int y) {
if (y >= s->top - s->aux) return filler_of(s->blk);
return B_STONE;
}
+
+/* ======================================================================== */
+/* Caves and ravines (WorldGenCaves, WorldGenCanyon) */
+/* ======================================================================== */
+
+/* A carve target: one chunk (tcx, tcz) and, inside it, the region we care about.
+ * mode CAVE_OUT: the chunk being generated (blocks in cout / summary csum).
+ * mode CAVE_MASK: a query box (world coords) whose carved blocks are marked in a bitmap;
+ * blocks come from the summary of the target chunk. */
+enum { CAVE_OUT, CAVE_MASK };
+
+typedef struct {
+ int mode;
+ int tcx, tcz;
+ const ColSum *sum; /* summary of the target chunk */
+ /* CAVE_OUT */
+ uint8_t *out;
+ int y0, h;
+ /* CAVE_MASK: box [bx0,bx1) x [by0,by1) x [bz0,bz1) in world coords, bitmap of carved cells */
+ int bx0, bx1, by0, by1, bz0, bz1;
+ uint8_t *mask;
+ /* region of the chunk that matters (chunk-local, inclusive-exclusive), for early skips */
+ int rx0, rx1, rz0, rz1, ry0, ry1;
+} CaveCtx;
+
+static CaveCtx *cv;
+static float canyon_w[256]; /* WorldGenCanyon.d */
+static uint8_t c_b16[256]; /* biomes of the chunk being generated */
+
+static inline int mask_index(int X, int Y, int Z) {
+ return ((Y - cv->by0) * (cv->bz1 - cv->bz0) + (Z - cv->bz0)) * (cv->bx1 - cv->bx0) + (X - cv->bx0);
+}
+
+/* block at chunk-local (x, y, z) of the target, as the carver sees it */
+static uint8_t cv_get(int x, int y, int z) {
+ if (y < 0 || y > 255) return B_AIR;
+ if (cv->mode == CAVE_OUT) {
+ if (y >= cv->y0 && y < cv->y0 + cv->h) return cv->out[(y - cv->y0) * 256 + z * 16 + x];
+ return sum_block(&cv->sum[x + z * 16], y);
+ }
+ int X = cv->tcx * 16 + x, Z = cv->tcz * 16 + z;
+ if (X >= cv->bx0 && X < cv->bx1 && y >= cv->by0 && y < cv->by1 && Z >= cv->bz0 && Z < cv->bz1) {
+ uint8_t m = cv->mask[mask_index(X, y, Z)];
+ if (m) return (uint8_t)(m - 1); /* mask stores block id + 1, 0 = untouched */
+ }
+ return sum_block(&cv->sum[x + z * 16], y);
+}
+
+static void cv_set(int x, int y, int z, uint8_t b) {
+ if (y < 0 || y > 255) return;
+ if (cv->mode == CAVE_OUT) {
+ if (y >= cv->y0 && y < cv->y0 + cv->h) cv->out[(y - cv->y0) * 256 + z * 16 + x] = b;
+ return;
+ }
+ int X = cv->tcx * 16 + x, Z = cv->tcz * 16 + z;
+ if (X >= cv->bx0 && X < cv->bx1 && y >= cv->by0 && y < cv->by1 && Z >= cv->bz0 && Z < cv->bz1)
+ cv->mask[mask_index(X, y, Z)] = (uint8_t)(b + 1);
+}
+
+/* is (x, y, z) water, for the carver's abort test: Java reads the chunk being carved,
+ * where water only comes from the terrain (summary-exact) */
+static inline int cv_water(int x, int y, int z) {
+ uint8_t b = cv_get(x, y, z);
+ return b == B_WATER || b == B_FLOWING_WATER;
+}
+
+/* position in 32.32 fixed point (world coordinates) */
+typedef i64 Q32;
+#define Q32_ONE (1LL << 32)
+static inline Q32 q32_of_float(float v) { return (Q32)(v * 4294967296.0f); }
+static inline float q32_to_float(Q32 v) { return (float)v * (1.0f / 4294967296.0f); }
+static inline int q32_floor(Q32 v) { return (int)(v >> 32); }
+
+/* One carve step of a tunnel (cave or canyon) into the target chunk.
+ * px,py,pz: centre; r6, r7: horizontal and vertical radii (Q32). */
+static int cave_carve(Q32 px, Q32 py, Q32 pz, Q32 r6, Q32 r7, int canyon) {
+ int j = cv->tcx, k = cv->tcz;
+ int l1 = q32_floor(px - r6) - j * 16 - 1, i2 = q32_floor(px + r6) - j * 16 + 1;
+ int j2 = q32_floor(py - r7) - 1, k2 = q32_floor(py + r7) + 1;
+ int l2 = q32_floor(pz - r6) - k * 16 - 1, i3 = q32_floor(pz + r6) - k * 16 + 1;
+ if (l1 < 0) l1 = 0;
+ if (i2 > 16) i2 = 16;
+ if (j2 < 1) j2 = 1;
+ if (k2 > 248) k2 = 248;
+ if (l2 < 0) l2 = 0;
+ if (i3 > 16) i3 = 16;
+ /* water check (shell of the box plus top and bottom layers): water aborts this step */
+ for (int x = l1; x < i2; x++)
+ for (int z = l2; z < i3; z++)
+ for (int y = k2 + 1; y >= j2 - 1; --y) {
+ if (y >= 0 && y < 256) {
+ if (cv_water(x, y, z)) return 0;
+ if (y != j2 - 1 && x != l1 && x != i2 - 1 && z != l2 && z != i3 - 1) y = j2;
+ }
+ }
+ /* skip carving where it cannot touch the region we care about (no other effect) */
+ if (l1 >= cv->rx1 || i2 <= cv->rx0 || l2 >= cv->rz1 || i3 <= cv->rz0 || j2 >= cv->ry1 || k2 + 1 < cv->ry0) return 1;
+ float d6 = q32_to_float(r6), d7 = q32_to_float(r7);
+ for (int x = l1; x < i2; x++) {
+ float d12 = q32_to_float(((Q32)(j * 16 + x) << 32) + (Q32_ONE >> 1) - px) / d6;
+ for (int z = l2; z < i3; z++) {
+ float d13 = q32_to_float(((Q32)(k * 16 + z) << 32) + (Q32_ONE >> 1) - pz) / d6;
+ float h2 = d12 * d12 + d13 * d13;
+ if (h2 >= 1.0f) continue;
+ int flag3 = 0;
+ for (int y = k2; y > j2; --y) {
+ float d14 = q32_to_float(((Q32)(y - 1) << 32) + (Q32_ONE >> 1) - py) / d7;
+ if (canyon) {
+ if (!(h2 * canyon_w[y - 1] + d14 * d14 / 6.0f < 1.0f)) continue;
+ uint8_t b = cv_get(x, y, z);
+ if (b == B_GRASS) flag3 = 1;
+ if (b == B_STONE || IS_DIRTISH(b) || b == B_GRASS) {
+ if (y - 1 < 10) {
+ cv_set(x, y, z, B_LAVA);
+ } else {
+ cv_set(x, y, z, B_AIR);
+ if (flag3 && IS_DIRTISH(cv_get(x, y - 1, z)))
+ cv_set(x, y - 1, z, bio(cv->mode == CAVE_OUT ? c_b16[x + z * 16] : BI_PLAINS)->top);
+ }
+ }
+ } else {
+ if (!(d14 > -0.7f && h2 + d14 * d14 < 1.0f)) continue;
+ uint8_t b = cv_get(x, y, z), up = cv_get(x, y + 1, z);
+ if (b == B_GRASS || b == B_MYCELIUM) flag3 = 1;
+ int carvable = b == B_STONE || IS_DIRTISH(b) || b == B_GRASS || IS_CLAY(b) || b == B_SANDSTONE ||
+ b == B_RED_SANDSTONE || b == B_MYCELIUM || b == B_SNOW_LAYER ||
+ ((b == B_SAND || b == B_RED_SAND || b == B_GRAVEL) && !IS_WATER(up));
+ if (!carvable) continue;
+ if (y - 1 < 10) {
+ cv_set(x, y, z, B_LAVA);
+ } else {
+ cv_set(x, y, z, B_AIR);
+ if (up == B_SAND) cv_set(x, y + 1, z, B_SANDSTONE);
+ else if (up == B_RED_SAND) cv_set(x, y + 1, z, B_RED_SANDSTONE);
+ if (flag3 && IS_DIRTISH(cv_get(x, y - 1, z))) {
+ uint8_t t = bio(cv->mode == CAVE_OUT ? c_b16[x + z * 16] : BI_PLAINS)->top;
+ if (t == B_PODZOL || t == B_COARSE_DIRT) t = B_DIRT; /* ak.getBlock().getBlockData() */
+ cv_set(x, y - 1, z, t);
+ }
+ }
+ }
+ }
+ }
+ }
+ return 1;
+}
+
+
+/* MapGenCaves' "cannot reach the chunk any more" test, d8^2 + d9^2 - d10^2 > d11^2, in float,
+ * settled in double when the float result is too close to call (the positions are exact) */
+static int cave_too_far(Q32 dx, Q32 dz, int d10i, float d11) {
+ float d8 = q32_to_float(dx), d9 = q32_to_float(dz), d10 = (float)d10i;
+ float lhs = d8 * d8 + d9 * d9 - d10 * d10, rhs = d11 * d11;
+ float diff = lhs - rhs;
+ if (diff > 0.05f) return 1;
+ if (diff < -0.05f) return 0;
+ double e8 = (double)dx * (1.0 / 4294967296.0), e9 = (double)dz * (1.0 / 4294967296.0), e10 = d10i, e11 = d11;
+ return e8 * e8 + e9 * e9 - e10 * e10 > e11 * e11;
+}
+
+/* tunnel stack (branches) */
+typedef struct {
+ i64 seed;
+ Q32 x, y, z;
+ float f, f1, f2;
+ int16_t l, i1;
+ uint8_t room;
+} Tunnel;
+#define TSTACK 24
+static Tunnel tstack[TSTACK];
+
+/* Walks one cave tunnel (WorldGenCaves.a, 13-argument version) and its branches. */
+static void cave_tunnel(i64 seed0, Q32 x0, Q32 y0, Q32 z0, float f0, float f10, float f20, int l0, int i10, int room0) {
+ int sp = 0;
+ tstack[sp++] = (Tunnel){seed0, x0, y0, z0, f0, f10, f20, (int16_t)l0, (int16_t)i10, (uint8_t)room0};
+ Q32 cxq = ((Q32)(cv->tcx * 16 + 8)) << 32, czq = ((Q32)(cv->tcz * 16 + 8)) << 32;
+ while (sp > 0) {
+ Tunnel t = tstack[--sp];
+ float f3 = 0, f4 = 0;
+ JRand r;
+ jr_seed(&r, t.seed);
+ int i1 = t.i1, l = t.l;
+ if (i1 <= 0) {
+ int j1 = 8 * 16 - 16;
+ i1 = j1 - jr_int(&r, j1 / 4);
+ }
+ int flag = 0;
+ if (t.room) {
+ l = i1 / 2;
+ flag = 1;
+ }
+ int k1 = jr_int(&r, i1 / 2) + i1 / 4;
+ int flag1 = jr_int(&r, 6) == 0;
+ float f = t.f, f1 = t.f1, f2 = t.f2;
+ Q32 d0 = t.x, d1 = t.y, d2 = t.z;
+ for (; l < i1; ++l) {
+ float sv = mh_sin((float)l * 3.1415927f / (float)i1) * f * 1.0f;
+ Q32 r6 = (Q32)(3LL << 31) + q32_of_float(sv); /* 1.5 + ... */
+ Q32 r7 = t.room ? r6 / 2 : r6;
+ float f5 = mh_cos(f2), f6 = mh_sin(f2);
+ d0 += q32_of_float(mh_cos(f1) * f5);
+ d1 += q32_of_float(f6);
+ d2 += q32_of_float(mh_sin(f1) * f5);
+ f2 *= flag1 ? 0.92f : 0.7f;
+ f2 += f4 * 0.1f;
+ f1 += f3 * 0.1f;
+ f4 *= 0.9f;
+ f3 *= 0.75f;
+ {
+ float a = jr_float(&r), b = jr_float(&r), c = jr_float(&r);
+ f4 += (a - b) * c * 2.0f;
+ }
+ {
+ float a = jr_float(&r), b = jr_float(&r), c = jr_float(&r);
+ f3 += (a - b) * c * 4.0f;
+ }
+ if (!flag && l == k1 && f > 1.0f && i1 > 0) {
+ if (sp + 2 <= TSTACK) {
+ i64 s1 = jr_long(&r);
+ float w1 = jr_float(&r) * 0.5f + 0.5f;
+ i64 s2 = jr_long(&r);
+ float w2 = jr_float(&r) * 0.5f + 0.5f;
+ /* second branch below the first: the first runs (with its sub-branches) first */
+ tstack[sp++] = (Tunnel){s2, d0, d1, d2, w2, f1 + 1.5707964f, f2 / 3.0f, (int16_t)l, (int16_t)i1, 0};
+ tstack[sp++] = (Tunnel){s1, d0, d1, d2, w1, f1 - 1.5707964f, f2 / 3.0f, (int16_t)l, (int16_t)i1, 0};
+ }
+ break;
+ }
+ if (flag || jr_int(&r, 4) != 0) {
+ float d8 = q32_to_float(d0 - cxq), d9 = q32_to_float(d2 - czq);
+ if (cave_too_far(d0 - cxq, d2 - czq, i1 - l, f + 2.0f + 16.0f)) break;
+ float lim = 16.0f + q32_to_float(r6) * 2.0f;
+ if (d8 >= -lim && d9 >= -lim && d8 <= lim && d9 <= lim) {
+ if (cave_carve(d0, d1, d2, r6, r7, 0) && flag) break;
+ }
+ }
+ }
+ }
+}
+
+static void canyon_tunnel(i64 seed, Q32 d0, Q32 d1, Q32 d2, float f, float f1, float f2) {
+ JRand r;
+ jr_seed(&r, seed);
+ Q32 cxq = ((Q32)(cv->tcx * 16 + 8)) << 32, czq = ((Q32)(cv->tcz * 16 + 8)) << 32;
+ float f3 = 0, f4 = 0;
+ int j1 = 8 * 16 - 16;
+ int i1 = j1 - jr_int(&r, j1 / 4);
+ int l = 0;
+ float f5 = 1.0f;
+ for (int k1 = 0; k1 < 256; ++k1) {
+ if (k1 == 0 || jr_int(&r, 3) == 0) {
+ float a = jr_float(&r), b = jr_float(&r);
+ f5 = 1.0f + a * b * 1.0f;
+ }
+ canyon_w[k1] = f5 * f5;
+ }
+ for (; l < i1; ++l) {
+ float sv = mh_sin((float)l * 3.1415927f / (float)i1) * f * 1.0f;
+ Q32 r6 = (Q32)(3LL << 31) + q32_of_float(sv);
+ Q32 r7 = r6 * 3; /* d3 = 3.0 */
+ /* d6 *= nextFloat * 0.25 + 0.75: nextFloat = n / 2^24, factor = (n + 3 * 2^24) / 2^26 */
+ i64 n6 = jr_next(&r, 24), n7 = jr_next(&r, 24);
+ r6 = (Q32)(((r6 >> 6) * (n6 + 3 * 16777216LL)) >> 20);
+ r7 = (Q32)(((r7 >> 6) * (n7 + 3 * 16777216LL)) >> 20);
+ float f6 = mh_cos(f2), f7 = mh_sin(f2);
+ d0 += q32_of_float(mh_cos(f1) * f6);
+ d1 += q32_of_float(f7);
+ d2 += q32_of_float(mh_sin(f1) * f6);
+ f2 *= 0.7f;
+ f2 += f4 * 0.05f;
+ f1 += f3 * 0.05f;
+ f4 *= 0.8f;
+ f3 *= 0.5f;
+ {
+ float a = jr_float(&r), b = jr_float(&r), c = jr_float(&r);
+ f4 += (a - b) * c * 2.0f;
+ }
+ {
+ float a = jr_float(&r), b = jr_float(&r), c = jr_float(&r);
+ f3 += (a - b) * c * 4.0f;
+ }
+ if (jr_int(&r, 4) != 0) {
+ float d8 = q32_to_float(d0 - cxq), d9 = q32_to_float(d2 - czq);
+ if (cave_too_far(d0 - cxq, d2 - czq, i1 - l, f + 2.0f + 16.0f)) return;
+ float lim = 16.0f + q32_to_float(r6) * 2.0f;
+ if (d8 >= -lim && d9 >= -lim && d8 <= lim && d9 <= lim) cave_carve(d0, d1, d2, r6, r7, 1);
+ }
+ }
+}
+
+/* MapGenBase.a for both caves and canyons, carving target cv */
+static void caves_run(void) {
+ int i = cv->tcx, j = cv->tcz;
+ JRand r;
+ for (int pass = 0; pass < 2; pass++) {
+ for (int j1 = i - 8; j1 <= i + 8; ++j1)
+ for (int k1 = j - 8; k1 <= j + 8; ++k1) {
+ jr_seed(&r, (i64)((u64)(i64)j1 * (u64)cave_mul_x) ^ (i64)((u64)(i64)k1 * (u64)cave_mul_z) ^ g_seed);
+ if (pass == 0) {
+ int n = jr_int(&r, jr_int(&r, jr_int(&r, 15) + 1) + 1);
+ if (jr_int(&r, 7) != 0) n = 0;
+ for (int c = 0; c < n; ++c) {
+ int xx = j1 * 16 + jr_int(&r, 16);
+ int yy = jr_int(&r, jr_int(&r, 120) + 8);
+ int zz = k1 * 16 + jr_int(&r, 16);
+ Q32 d0 = (Q32)xx << 32, d1 = (Q32)yy << 32, d2 = (Q32)zz << 32;
+ int k = 1;
+ if (jr_int(&r, 4) == 0) {
+ i64 s = jr_long(&r);
+ float w = 1.0f + jr_float(&r) * 6.0f;
+ cave_tunnel(s, d0, d1, d2, w, 0.0f, 0.0f, -1, -1, 1);
+ k += jr_int(&r, 4);
+ }
+ for (int l1 = 0; l1 < k; ++l1) {
+ float f = jr_float(&r) * 3.1415927f * 2.0f;
+ float f1 = (jr_float(&r) - 0.5f) * 2.0f / 8.0f;
+ float f2 = jr_float(&r) * 2.0f + jr_float(&r);
+ if (jr_int(&r, 10) == 0) {
+ float a = jr_float(&r), b = jr_float(&r);
+ f2 *= a * b * 3.0f + 1.0f;
+ }
+ cave_tunnel(jr_long(&r), d0, d1, d2, f2, f, f1, 0, 0, 0);
+ }
+ }
+ } else if (jr_int(&r, 50) == 0) {
+ int xx = j1 * 16 + jr_int(&r, 16);
+ int yy = jr_int(&r, jr_int(&r, 40) + 8) + 20;
+ int zz = k1 * 16 + jr_int(&r, 16);
+ float f = jr_float(&r) * 3.1415927f * 2.0f;
+ float f1 = (jr_float(&r) - 0.5f) * 2.0f / 8.0f;
+ float f2 = (jr_float(&r) * 2.0f + jr_float(&r)) * 2.0f;
+ canyon_tunnel(jr_long(&r), (Q32)xx << 32, (Q32)yy << 32, (Q32)zz << 32, f2, f, f1);
+ }
+ }
+ }
+}
+
+/* ======================================================================== */
+/* Summary cache */
+/* ======================================================================== */
+
+#define NSUM 12
+typedef struct {
+ int cx, cz;
+ uint32_t age;
+ uint8_t valid;
+ ColSum s[256];
+} SumEntry;
+static SumEntry sumc[NSUM];
+static uint32_t sum_clock;
+
+static SumEntry *sum_find(int cx, int cz) {
+ for (int i = 0; i < NSUM; i++)
+ if (sumc[i].valid && sumc[i].cx == cx && sumc[i].cz == cz) {
+ sumc[i].age = ++sum_clock;
+ return &sumc[i];
+ }
+ return 0;
+}
+
+/* entry to (re)fill: the least recently used one not pinned */
+static uint8_t sum_pin[NSUM];
+static SumEntry *sum_slot(int cx, int cz) {
+ int best = -1;
+ for (int i = 0; i < NSUM; i++) {
+ if (sum_pin[i]) continue;
+ if (!sumc[i].valid) {
+ best = i;
+ break;
+ }
+ if (best < 0 || sumc[i].age < sumc[best].age) best = i;
+ }
+ SumEntry *e = &sumc[best];
+ e->cx = cx;
+ e->cz = cz;
+ e->valid = 1;
+ e->age = ++sum_clock;
+ return e;
+}
+
+static SumEntry *sum_get(int cx, int cz) {
+ SumEntry *e = sum_find(cx, cz);
+ if (e) return e;
+ e = sum_slot(cx, cz);
+ chunk_terrain(cx, cz, 0, 0, 0, e->s);
+ return e;
+}
+
+/* the 3x3 summaries around the chunk being generated, pinned during gen_slab */
+static SumEntry *nb[3][3]; /* [dz+1][dx+1] */
+static int nb_cx, nb_cz;
+
+static const ColSum *col_sum(int X, int Z) {
+ int cx = X >> 4, cz = Z >> 4;
+ int dx = cx - nb_cx + 1, dz = cz - nb_cz + 1;
+ if (dx < 0 || dx > 2 || dz < 0 || dz > 2) return 0;
+ return &nb[dz][dx]->s[(X & 15) + (Z & 15) * 16];
+}
+
+/* ======================================================================== */
+/* Population: the chunk being generated (C), the view of a population (P) */
+/* ======================================================================== */
+
+/* chunk C: blocks for y in [c_y0, c_y0 + c_h) in c_out; c_top: highest non-air y of each column
+ * (whole height), c_sl: highest solid-or-liquid y (precipitation height - 1) */
+static uint8_t *c_out;
+static int c_y0, c_h, c_cx, c_cz;
+static uint8_t c_top[256], c_sl[256];
+
+#define PV (U.p.v)
+
+static inline int lake_bit(const LakeRec *L, int x, int y, int z) {
+ int i = (x * 16 + z) * 8 + y;
+ return (L->shape[i >> 3] >> (i & 7)) & 1;
+}
+
+/* view block at world (X, Y, Z) */
+static uint8_t vget(int X, int Y, int Z) {
+ if (Y < 0) return B_BEDROCK;
+ if (Y > 255) return B_AIR;
+ View *v = &PV;
+ int lx = X - v->ox, lz = Z - v->oz;
+ if (lx < 0) lx = 0;
+ if (lx > 31) lx = 31;
+ if (lz < 0) lz = 0;
+ if (lz > 31) lz = 31;
+ X = v->ox + lx;
+ Z = v->oz + lz;
+ int i = lz * 32 + lx;
+ if (Y > v->top[i]) return (Y == v->top[i] + 1 && v->pl[i]) ? v->pl[i] : B_AIR;
+ if (Y == v->top[i]) return v->tb[i];
+ for (int k = 0; k < v->nlake; k++) {
+ const LakeRec *L = &v->lake[k];
+ int ax = X - L->x, ay = Y - L->y, az = Z - L->z;
+ if (ax >= 0 && ax < 16 && az >= 0 && az < 16 && ay >= 0 && ay < 8 && lake_bit(L, ax, ay, az))
+ return ay >= 4 ? B_AIR : L->liquid;
+ }
+ const ColSum *s = col_sum(X, Z);
+ if (!s) return Y < SEA ? B_STONE : B_AIR;
+ if (Y > s->top) return B_AIR;
+ if (v->qon && X >= v->qx0 && X < v->qx1 && Y >= v->qy0 && Y < v->qy1 && Z >= v->qz0 && Z < v->qz1) {
+ uint8_t m = U.p.qmask[((Y - v->qy0) * (v->qz1 - v->qz0) + (Z - v->qz0)) * (v->qx1 - v->qx0) + (X - v->qx0)];
+ if (m) return (uint8_t)(m - 1);
+ }
+ return sum_block(s, Y);
+}
+
+static inline int v_empty(int X, int Y, int Z) { return vget(X, Y, Z) == B_AIR; }
+
+/* World.getHighestBlockYAt(...).getY(): first y above the highest opaque block */
+static int hm(int X, int Z) {
+ View *v = &PV;
+ int lx = X - v->ox, lz = Z - v->oz;
+ if (lx < 0) lx = 0;
+ if (lx > 31) lx = 31;
+ if (lz < 0) lz = 0;
+ if (lz > 31) lz = 31;
+ return v->top[lz * 32 + lx] + 1;
+}
+
+/* World.r(pos) (top solid-or-liquid... actually top solid non-leaves block) + 1 */
+static int top_solid(int X, int Z) {
+ int y = hm(X, Z) + 1;
+ for (; y >= 0; y--) {
+ uint8_t b = vget(X, y, Z);
+ if (IS_SOLID(b) && !IS_LEAVES(b)) break;
+ }
+ return y + 1;
+}
+
+/* write rules: checked against C's real blocks before a write lands in C */
+enum {
+ R_ALWAYS, R_TREE, /* air, leaves, replaceable plant */
+ R_AIRLEAF, R_NOTCUBE, R_TREEOK, R_AIR, R_STONE, R_DIRTGRASS, R_DIRTCLAY, R_ICE, R_ICE2, R_BUILD,
+ R_NOTCHEST, R_WALL, R_SAND_SANDY
+};
+
+static int rule_ok(int rule, uint8_t b) {
+ switch (rule) {
+ case R_ALWAYS: return 1;
+ case R_TREE: return b == B_AIR || IS_LEAVES(b) || IS_RPLANT(b);
+ case R_AIRLEAF: return b == B_AIR || IS_LEAVES(b);
+ case R_NOTCUBE: return !IS_CUBE(b);
+ case R_TREEOK:
+ return b == B_AIR || IS_LEAVES(b) || b == B_GRASS || IS_DIRTISH(b) || IS_LOG(b) || b == B_VINE ||
+ (b >= B_SAPLING_OAK && b <= B_SAPLING_DARK_OAK);
+ case R_AIR: return b == B_AIR;
+ case R_STONE: return b == B_STONE;
+ case R_DIRTGRASS: return IS_DIRTISH(b) || b == B_GRASS;
+ case R_DIRTCLAY: return IS_DIRTISH(b) || b == B_CLAY;
+ case R_ICE: return b == B_AIR || IS_DIRTISH(b) || b == B_SNOW || b == B_ICE;
+ case R_ICE2: return b == B_AIR || IS_DIRTISH(b) || b == B_SNOW || b == B_ICE || b == B_PACKED_ICE;
+ case R_BUILD: return IS_BUILD(b);
+ case R_NOTCHEST: return b != B_CHEST;
+ case R_WALL: return IS_BUILD(b) && b != B_CHEST;
+ }
+ return 1;
+}
+
+static inline int is_plantish(uint8_t b) {
+ return IS_PLANT(b) || IS_RPLANT(b) || b == B_CACTUS || b == B_SNOW_LAYER || b == B_SUGAR_CANE;
+}
+
+/* top of column (x, z) of C after removing the block at y: next non-air below */
+static void c_lower_top(int i, int y) {
+ int x = i & 15, z = i >> 4;
+ const ColSum *s = &nb[1][1]->s[i];
+ while (y > 0) {
+ y--;
+ uint8_t b = (y >= c_y0 && y < c_y0 + c_h) ? c_out[(y - c_y0) * 256 + z * 16 + x] : sum_block(s, y);
+ if (b != B_AIR) break;
+ }
+ c_top[i] = (uint8_t)y;
+}
+
+/* chunk C bookkeeping for a block that was (or, out of the y range, presumably was) written */
+static void c_track(int i, int Y, uint8_t b) {
+ if (b == B_AIR) {
+ if (Y == c_top[i]) c_lower_top(i, Y);
+ if (Y == c_sl[i]) c_sl[i] = c_top[i] < c_sl[i] ? c_top[i] : (uint8_t)(Y - 1);
+ } else {
+ if (Y > c_top[i]) c_top[i] = (uint8_t)Y;
+ if ((IS_SOLID(b) || (bflags[b] & BF_LIQUID)) && Y > c_sl[i]) c_sl[i] = (uint8_t)Y;
+ }
+}
+
+/* writes block b at world (X, Y, Z): into the view, and into C if the rule holds there */
+static void put(int X, int Y, int Z, uint8_t b, int rule) {
+ if (Y < 0 || Y > 255) return;
+ View *v = &PV;
+ int lx = X - v->ox, lz = Z - v->oz;
+ if (lx >= 0 && lx < 32 && lz >= 0 && lz < 32) {
+ int i = lz * 32 + lx;
+ if (b == B_AIR) {
+ if (Y == v->top[i] + 1) v->pl[i] = 0;
+ if (Y == v->top[i]) {
+ v->pl[i] = 0;
+ int y = Y;
+ v->top[i] = (uint8_t)(Y - 1); /* provisional so vget sees below */
+ while (y > 0) {
+ y--;
+ v->top[i] = (uint8_t)y;
+ v->tb[i] = B_AIR;
+ /* read what lies below with the column top above it */
+ v->top[i] = 255;
+ uint8_t u = vget(X, y, Z);
+ v->top[i] = (uint8_t)y;
+ if (u != B_AIR) {
+ v->tb[i] = u;
+ break;
+ }
+ }
+ }
+ } else if (is_plantish(b)) {
+ if (Y == v->top[i] + 1) v->pl[i] = b;
+ } else {
+ if (Y > v->top[i]) {
+ v->top[i] = (uint8_t)Y;
+ v->tb[i] = b;
+ v->pl[i] = 0;
+ } else if (Y == v->top[i]) {
+ v->tb[i] = b;
+ }
+ }
+ }
+ int cx = X - c_cx * 16, cz = Z - c_cz * 16;
+ if (cx >= 0 && cx < 16 && cz >= 0 && cz < 16) {
+ int i = cz * 16 + cx;
+ if (Y >= c_y0 && Y < c_y0 + c_h) {
+ uint8_t *o = &c_out[(Y - c_y0) * 256 + i];
+ if (!rule_ok(rule, *o)) return;
+ *o = b;
+ }
+ c_track(i, Y, b);
+ }
+}
+
+/* only into C (features whose result never feeds a later decision: ores...) */
+static void put_c(int X, int Y, int Z, uint8_t b, int rule) {
+ int cx = X - c_cx * 16, cz = Z - c_cz * 16;
+ if (cx < 0 || cx > 15 || cz < 0 || cz > 15 || Y < c_y0 || Y >= c_y0 + c_h) return;
+ uint8_t *o = &c_out[(Y - c_y0) * 256 + cz * 16 + cx];
+ if (rule_ok(rule, *o)) {
+ *o = b;
+ c_track(cz * 16 + cx, Y, b);
+ }
+}
+
+/* C's real block if (X, Y, Z) is in C and in range, else the view's */
+static uint8_t cget(int X, int Y, int Z) {
+ int cx = X - c_cx * 16, cz = Z - c_cz * 16;
+ if (cx >= 0 && cx < 16 && cz >= 0 && cz < 16 && Y >= c_y0 && Y < c_y0 + c_h)
+ return c_out[(Y - c_y0) * 256 + cz * 16 + cx];
+ return vget(X, Y, Z);
+}
+
+static inline int in_c_range(int X, int Y, int Z) {
+ int cx = X - c_cx * 16, cz = Z - c_cz * 16;
+ return cx >= 0 && cx < 16 && cz >= 0 && cz < 16 && Y >= c_y0 && Y < c_y0 + c_h;
+}
+
+static inline int in_c_cols(int X, int Z) {
+ int cx = X - c_cx * 16, cz = Z - c_cz * 16;
+ return cx >= 0 && cx < 16 && cz >= 0 && cz < 16;
+}
diff --git a/games/numblocks/src/main.c b/games/numblocks/src/main.c
index 727ccadd..b494f86c 100644
--- a/games/numblocks/src/main.c
+++ b/games/numblocks/src/main.c
@@ -159,6 +159,7 @@ bool game_frame(void) {
}
world_follow(pl.x, pl.y, pl.z);
float t = acc / 50.0f;
+ tick_frac = t;
Camera c = {px + (pl.x - px) * t, py + (pl.y - py) * t + (pl.sneaking ? 1.54f : 1.62f), pz + (pl.z - pz) * t, pl.yaw,
pl.pitch};
if (pl.dead) c.y = pl.y + 0.3f;
diff --git a/games/numblocks/src/mob.c b/games/numblocks/src/mob.c
new file mode 100644
index 00000000..45ab1f0d
--- /dev/null
+++ b/games/numblocks/src/mob.c
@@ -0,0 +1,660 @@
+/* Mobs: their models (mob.h), how they move, fight, spawn and die.
+ *
+ * Minecraft 1.8.8's numbers: health, speed, damage (scaled by difficulty),
+ * the walk animation, zombies and skeletons burning in daylight, creepers'
+ * 1.5 second fuse and power 3 explosion, skeletons' arrows, spiders neutral
+ * in daylight, animals wandering and panicking when hit, and the loot. The
+ * AI steers straight at its target instead of searching a path, jumping over
+ * single blocks; mobs spawn in the dark from 14 blocks away (the calculator
+ * keeps only about 20 blocks of the world around you). */
+#include <math.h>
+#include <stdlib.h>
+#include "mob.h"
+
+/* ---------------------------------------------------------------- what each mob is */
+typedef struct {
+ float w, h, speed;
+ uint8_t health;
+} MobInfo;
+static const MobInfo info[] = {
+ [E_ZOMBIE] = {0.6f, 1.95f, 0.23f, 20}, [E_SKELETON] = {0.6f, 1.99f, 0.25f, 20},
+ [E_CREEPER] = {0.6f, 1.7f, 0.25f, 20}, [E_SPIDER] = {1.4f, 0.9f, 0.3f, 16},
+ [E_PIG] = {0.9f, 0.9f, 0.25f, 10}, [E_COW] = {0.9f, 1.3f, 0.2f, 10},
+ [E_SHEEP] = {0.9f, 1.3f, 0.23f, 8}, [E_CHICKEN] = {0.4f, 0.7f, 0.25f, 4},
+};
+float mob_width(int t) { return t >= E_ZOMBIE && t <= E_CHICKEN ? info[t].w : 0.25f; }
+float mob_height(int t) { return t >= E_ZOMBIE && t <= E_CHICKEN ? info[t].h : 0.25f; }
+static bool hostile(int t) { return t >= E_ZOMBIE && t <= E_SPIDER; }
+
+float mob_scale(const Entity *e, float pt) {
+ if (e->type != E_CREEPER || e->delay <= 0) return 1;
+ /* RenderCreeper: swells by up to 40% (and flickers) over the fuse */
+ float f = (e->delay + pt) / 28.0f;
+ if (f > 1) f = 1;
+ return 1 + f * f * f * f * 0.4f;
+}
+
+/* ---------------------------------------------------------------- models */
+static int np;
+static Part *out_parts;
+static Part *box(float x, float y, float z, int w, int h, int d, int u, int v, float px, float py, float pz, int skin) {
+ Part *p = &out_parts[np++];
+ *p = (Part){x, y, z, (uint8_t)w, (uint8_t)h, (uint8_t)d, (uint8_t)u, (uint8_t)v, 0, (uint8_t)skin, px, py, pz, 0, 0,
+ 0, 0};
+ return p;
+}
+
+#define PI 3.14159265f
+int mob_parts(const Entity *e, float pt, Part *o) {
+ np = 0;
+ out_parts = o;
+ float f = e->limb + e->limb_amt * pt, a = e->limb_amt; /* limbSwing, limbSwingAmount */
+ if (a > 1) a = 1;
+ float pitch = e->pitch * 0.017453292f, age = e->age + pt;
+ float sw = cosf(f * 0.6662f), swo = cosf(f * 0.6662f + PI);
+ switch (e->type) {
+ case E_ZOMBIE:
+ case E_SKELETON: {
+ int sk = e->type == E_ZOMBIE ? SKIN_ZOMBIE : SKIN_SKELETON;
+ box(-4, -8, -4, 8, 8, 8, 0, 0, 0, 0, 0, sk)->rx = pitch;
+ box(-4, 0, -2, 8, 12, 4, 16, 16, 0, 0, 0, sk);
+ Part *ra, *la, *rl, *ll;
+ if (e->type == E_ZOMBIE) {
+ ra = box(-3, -2, -2, 4, 12, 4, 40, 16, -5, 2, 0, sk);
+ la = box(-1, -2, -2, 4, 12, 4, 40, 16, 5, 2, 0, sk);
+ rl = box(-2, 0, -2, 4, 12, 4, 0, 16, -1.9f, 12, 0, sk);
+ ll = box(-2, 0, -2, 4, 12, 4, 0, 16, 1.9f, 12, 0, sk);
+ /* ModelZombie: arms held out, swaying a little */
+ ra->rx = la->rx = -PI / 2 + sinf(age * 0.067f) * 0.05f;
+ ra->rz = cosf(age * 0.09f) * 0.05f + 0.05f;
+ la->rz = -ra->rz;
+ } else {
+ ra = box(-1, -2, -1, 2, 12, 2, 40, 16, -5, 2, 0, sk);
+ la = box(-1, -2, -1, 2, 12, 2, 40, 16, 5, 2, 0, sk);
+ rl = box(-1, 0, -1, 2, 12, 2, 0, 16, -2, 12, 0, sk);
+ ll = box(-1, 0, -1, 2, 12, 2, 0, 16, 2, 12, 0, sk);
+ /* aiming its bow */
+ ra->rx = la->rx = -PI / 2 + pitch;
+ ra->ry = -0.1f;
+ la->ry = 0.5f;
+ }
+ la->mirror = ll->mirror = 1;
+ rl->rx = sw * 1.4f * a;
+ ll->rx = swo * 1.4f * a;
+ break;
+ }
+ case E_CREEPER: {
+ box(-4, -8, -4, 8, 8, 8, 0, 0, 0, 6, 0, SKIN_CREEPER)->rx = pitch;
+ box(-4, 0, -2, 8, 12, 4, 16, 16, 0, 6, 0, SKIN_CREEPER);
+ box(-2, 0, -2, 4, 6, 4, 0, 16, -2, 18, 4, SKIN_CREEPER)->rx = sw * 1.4f * a;
+ box(-2, 0, -2, 4, 6, 4, 0, 16, 2, 18, 4, SKIN_CREEPER)->rx = swo * 1.4f * a;
+ box(-2, 0, -2, 4, 6, 4, 0, 16, -2, 18, -4, SKIN_CREEPER)->rx = swo * 1.4f * a;
+ box(-2, 0, -2, 4, 6, 4, 0, 16, 2, 18, -4, SKIN_CREEPER)->rx = sw * 1.4f * a;
+ break;
+ }
+ case E_SPIDER: {
+ box(-4, -4, -8, 8, 8, 8, 32, 4, 0, 15, -3, SKIN_SPIDER)->rx = pitch;
+ box(-3, -3, -3, 6, 6, 6, 0, 0, 0, 15, 0, SKIN_SPIDER);
+ box(-5, -4, -6, 10, 8, 12, 0, 12, 0, 15, 9, SKIN_SPIDER);
+ /* ModelSpider: eight legs fanned out, swinging in pairs */
+ static const float rz[8] = {-0.7853982f, 0.7853982f, -0.5811946f, 0.5811946f, -0.5811946f, 0.5811946f,
+ -0.7853982f, 0.7853982f};
+ static const float ry[8] = {0.7853982f, -0.7853982f, 0.3926991f, -0.3926991f, -0.3926991f, 0.3926991f,
+ -0.7853982f, 0.7853982f};
+ static const float pzs[4] = {2, 1, 0, -1};
+ float g = f * 0.6662f * 2;
+ float swy[4] = {-cosf(g) * 0.4f * a, -cosf(g + PI) * 0.4f * a, -cosf(g + PI / 2) * 0.4f * a,
+ -cosf(g + PI * 1.5f) * 0.4f * a};
+ float swz[4] = {fabsf(sinf(f * 0.6662f)) * 0.4f * a, fabsf(sinf(f * 0.6662f + PI)) * 0.4f * a,
+ fabsf(sinf(f * 0.6662f + PI / 2)) * 0.4f * a, fabsf(sinf(f * 0.6662f + PI * 1.5f)) * 0.4f * a};
+ for (int l = 0; l < 8; l++) {
+ bool right = !(l & 1);
+ Part *p = box(right ? -15 : -1, -1, -1, 16, 2, 2, 18, 0, right ? -4 : 4, 15, pzs[l >> 1], SKIN_SPIDER);
+ p->rz = rz[l] + (right ? swz[l >> 1] : -swz[l >> 1]);
+ p->ry = ry[l] + (right ? swy[l >> 1] : -swy[l >> 1]);
+ }
+ break;
+ }
+ case E_PIG:
+ case E_COW:
+ case E_SHEEP: {
+ int sk = e->type == E_PIG ? SKIN_PIG : e->type == E_COW ? SKIN_COW : SKIN_SHEEP;
+ float lh = e->type == E_PIG ? 6 : 12;
+ Part *body;
+ if (e->type == E_PIG) {
+ box(-4, -4, -8, 8, 8, 8, 0, 0, 0, 12, -6, sk)->rx = pitch;
+ box(-2, 0, -9, 4, 3, 1, 16, 16, 0, 12, -6, sk)->rx = pitch; /* the snout */
+ body = box(-5, -10, -7, 10, 16, 8, 28, 8, 0, 11, 2, sk);
+ } else if (e->type == E_COW) {
+ box(-4, -4, -6, 8, 8, 6, 0, 0, 0, 4, -8, sk)->rx = pitch;
+ box(-5, -5, -4, 1, 3, 1, 22, 0, 0, 4, -8, sk)->rx = pitch; /* horns */
+ box(4, -5, -4, 1, 3, 1, 22, 0, 0, 4, -8, sk)->rx = pitch;
+ body = box(-6, -10, -7, 12, 18, 10, 18, 4, 0, 5, 2, sk);
+ box(-2, 2, -8, 4, 6, 1, 52, 0, 0, 5, 2, sk)->rx = PI / 2; /* the udder */
+ } else {
+ box(-3, -4, -6, 6, 6, 8, 0, 0, 0, 6, -8, sk)->rx = pitch;
+ body = box(-4, -10, -7, 8, 16, 6, 28, 8, 0, 5, 2, sk);
+ }
+ body->rx = PI / 2;
+ float lx = e->type == E_COW ? 4 : 3, lz0 = 7, lz1 = e->type == E_COW ? -6 : -5;
+ float ly = 24 - lh;
+ Part *l1 = box(-2, 0, -2, 4, (int)lh, 4, 0, 16, -lx, ly, lz0, sk);
+ Part *l2 = box(-2, 0, -2, 4, (int)lh, 4, 0, 16, lx, ly, lz0, sk);
+ Part *l3 = box(-2, 0, -2, 4, (int)lh, 4, 0, 16, -lx, ly, lz1, sk);
+ Part *l4 = box(-2, 0, -2, 4, (int)lh, 4, 0, 16, lx, ly, lz1, sk);
+ l1->rx = l4->rx = sw * 1.4f * a;
+ l2->rx = l3->rx = swo * 1.4f * a;
+ if (e->type == E_SHEEP && !e->sheared) {
+ /* the wool (ModelSheep1), inflated */
+ Part *h = box(-3, -4, -4, 6, 6, 6, 0, 0, 0, 6, -8, SKIN_SHEEP_FUR);
+ h->grow = 0.6f, h->rx = pitch;
+ Part *b = box(-4, -10, -7, 8, 16, 6, 28, 8, 0, 5, 2, SKIN_SHEEP_FUR);
+ b->grow = 1.75f, b->rx = PI / 2;
+ Part *ls[4] = {l1, l2, l3, l4};
+ for (int k = 0; k < 4; k++) {
+ Part *w = box(-2, 0, -2, 4, 6, 4, 0, 16, ls[k]->px, ls[k]->py, ls[k]->pz, SKIN_SHEEP_FUR);
+ w->grow = 0.5f, w->rx = ls[k]->rx;
+ }
+ }
+ break;
+ }
+ case E_CHICKEN: {
+ float hp = pitch;
+ box(-2, -6, -2, 4, 6, 3, 0, 0, 0, 15, -4, SKIN_CHICKEN)->rx = hp;
+ box(-2, -4, -4, 4, 2, 2, 14, 0, 0, 15, -4, SKIN_CHICKEN)->rx = hp; /* the bill */
+ box(-1, -2, -3, 2, 2, 2, 14, 4, 0, 15, -4, SKIN_CHICKEN)->rx = hp; /* the wattle */
+ box(-3, -4, -3, 6, 8, 6, 0, 9, 0, 16, 0, SKIN_CHICKEN)->rx = PI / 2;
+ box(-1, 0, -3, 3, 5, 3, 26, 0, -2, 19, 1, SKIN_CHICKEN)->rx = sw * 1.4f * a;
+ box(-1, 0, -3, 3, 5, 3, 26, 0, 1, 19, 1, SKIN_CHICKEN)->rx = swo * 1.4f * a;
+ float flap = e->on_ground ? 0 : (sinf(age * 1.5f) + 1) * 0.6f;
+ box(0, 0, -3, 1, 4, 6, 24, 13, -4, 13, 0, SKIN_CHICKEN)->rz = flap;
+ box(-1, 0, -3, 1, 4, 6, 24, 13, 4, 13, 0, SKIN_CHICKEN)->rz = -flap;
+ break;
+ }
+ }
+ return np;
+}
+
+/* ---------------------------------------------------------------- the world around a mob */
+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;
+}
+/* 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);
+ /* 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;
+ return sky < 0 ? 0 : sky;
+}
+/* a torch's light reaches here (block light 8 or more: 7 blocks from a torch) */
+static bool lit_by_blocks(int x, int y, int z) {
+ for (int dy = -6; dy <= 6; dy++)
+ for (int dz = -6; dz <= 6; dz++)
+ for (int dx = -6; dx <= 6; dx++) {
+ int m = abs(dx) + abs(dy) + abs(dz);
+ if (m > 7) continue;
+ int b = world_get(x + dx, y + dy, z + dz);
+ if (blk_light[b] && blk_light[b] - m >= 8) return true;
+ }
+ return false;
+}
+static bool can_stand(int x, int y, int z) {
+ int below = world_get(x, y - 1, z), feet = world_get(x, y, z), head = world_get(x, y + 1, z);
+ return (blk_flags[below] & BF_OPAQUE) && !(blk_flags[feet] & BF_SOLID) && blk_model[feet] != M_LIQUID &&
+ !(blk_flags[head] & BF_SOLID) && blk_model[head] != M_LIQUID;
+}
+
+/* ---------------------------------------------------------------- spawning */
+static int count(bool host) {
+ int n = 0;
+ for (int i = 0; i < N_ENT; i++)
+ if (ents[i].type >= E_ZOMBIE && ents[i].type <= E_CHICKEN && hostile(ents[i].type) == host) n++;
+ return n;
+}
+
+static Entity *spawn(int type, float x, float y, float z) {
+ Entity *e = ent_new(type, x, y, z);
+ if (!e) return NULL;
+ e->health = info[type].health;
+ e->yaw = rndf() * 360;
+ e->gx = x, e->gz = z;
+ return e;
+}
+
+/* SpawnerAnimals, made small: a try every second */
+void mobs_spawn(void) {
+ if (pl.dead) return;
+ for (int k = 0; k < 4; k++) {
+ int x = ifl(pl.x) + rnd(41) - 20, z = ifl(pl.z) + rnd(41) - 20;
+ float dx = x + 0.5f - pl.x, dz = z + 0.5f - pl.z;
+ if (dx * dx + dz * dz < 14 * 14) continue;
+ int y0 = ifl(pl.y) + 8;
+ for (int y = y0; y > y0 - 20; y--) {
+ if (!world_loaded(x, y + 1, z) || !world_loaded(x, y - 1, z)) continue;
+ if (!can_stand(x, y, z)) continue;
+ int below = world_get(x, y - 1, z);
+ int light = light_there(x, y, z);
+ if (opt.difficulty > 0 && count(true) < 4 && light <= rnd(8) && below != B_BEDROCK &&
+ !lit_by_blocks(x, y, z)) {
+ static const uint8_t kinds[4] = {E_ZOMBIE, E_SKELETON, E_CREEPER, E_SPIDER};
+ int t = kinds[rnd(4)];
+ if (t == E_SPIDER && !(can_stand(x + 1, y, z) && can_stand(x, y, z + 1))) t = E_ZOMBIE;
+ spawn(t, x + 0.5f, (float)y, z + 0.5f);
+ return;
+ }
+ if (below == B_GRASS && light > 8 && count(false) < 4 && rnd(4) == 0) {
+ /* sheep 12, pig 10, chicken 10, cow 8 */
+ int r = rnd(40);
+ int t = r < 12 ? E_SHEEP : r < 22 ? E_PIG : r < 32 ? E_CHICKEN : E_COW;
+ int n = 1 + rnd(2);
+ for (int i = 0; i < n; i++) spawn(t, x + 0.5f + i * 0.3f, (float)y, z + 0.5f);
+ return;
+ }
+ break;
+ }
+ }
+}
+
+/* ---------------------------------------------------------------- dying, loot */
+static void drop(int id, int n, const Entity *e) {
+ if (n > 0) ent_drop(id, n, 0, e->x, e->y + 0.5f, e->z, false);
+}
+static void loot(Entity *e) {
+ switch (e->type) {
+ case E_ZOMBIE: drop(I_ROTTEN_FLESH, rnd(3), e); break;
+ case E_SKELETON:
+ drop(I_BONE, rnd(3), e);
+ drop(I_ARROW, rnd(3), e);
+ break;
+ case E_CREEPER: drop(I_GUNPOWDER, rnd(3), e); break;
+ case E_SPIDER:
+ drop(I_STRING, rnd(3), e);
+ if (rnd(3) == 0) drop(I_SPIDER_EYE, 1, e);
+ break;
+ case E_PIG: drop(e->fire > 0 ? I_COOKED_PORKCHOP : I_PORKCHOP, 1 + rnd(3), e); break;
+ case E_COW:
+ drop(e->fire > 0 ? I_COOKED_BEEF : I_BEEF, 1 + rnd(3), e);
+ drop(I_LEATHER, rnd(3), e);
+ break;
+ case E_SHEEP:
+ if (!e->sheared) drop(B_WOOL_WHITE, 1, e);
+ drop(e->fire > 0 ? I_COOKED_MUTTON : I_MUTTON, 1 + rnd(2), e);
+ break;
+ case E_CHICKEN:
+ drop(I_FEATHER, rnd(3), e);
+ drop(e->fire > 0 ? I_COOKED_CHICKEN : I_CHICKEN, 1, e);
+ break;
+ }
+ player_add_xp(hostile(e->type) ? 5 : 1 + rnd(3));
+}
+
+static void hurt(Entity *e, float dmg, float kx, float kz) {
+ if (e->state == 255 || e->invuln > 10) return;
+ e->health = (int16_t)(e->health - (int)ceilf(dmg));
+ e->invuln = 20;
+ e->hurt = 10;
+ /* EntityLivingBase.knockBack */
+ float d = sqrtf(kx * kx + kz * kz);
+ if (d > 0) {
+ e->vx = e->vx / 2 + kx / d * 0.4f;
+ e->vz = e->vz / 2 + kz / d * 0.4f;
+ e->vy = e->vy / 2 + 0.4f;
+ if (e->vy > 0.4f) e->vy = 0.4f;
+ }
+ if (!hostile(e->type)) e->panic = 100;
+ if (e->type == E_SPIDER) e->panic = 600; /* a hit spider fights back, even by day */
+ if (e->health <= 0) {
+ e->state = 255;
+ e->timer = 0;
+ }
+}
+
+/* ---------------------------------------------------------------- the player and mobs */
+Entity *entity_looked_at(float reach, float block_t) {
+ float ex = pl.x, ey = pl.y + (pl.sneaking ? 1.54f : 1.62f), ez = pl.z;
+ float yaw = pl.yaw * 0.017453292f, pitch = pl.pitch * 0.017453292f;
+ float d[3] = {-sinf(yaw) * cosf(pitch), -sinf(pitch), cosf(yaw) * cosf(pitch)};
+ float best = reach < block_t ? reach : block_t;
+ Entity *hit = NULL;
+ for (int i = 0; i < N_ENT; i++) {
+ Entity *e = &ents[i];
+ if (e->type < E_ZOMBIE || e->type > E_CHICKEN || e->state == 255) continue;
+ float w = info[e->type].w / 2 + 0.1f, h = info[e->type].h + 0.1f;
+ float lo[3] = {e->x - w, e->y, e->z - w}, hi[3] = {e->x + w, e->y + h, e->z + w}, o[3] = {ex, ey, ez};
+ float t0 = 0, t1 = best;
+ bool miss = false;
+ for (int a = 0; a < 3 && !miss; a++) {
+ if (fabsf(d[a]) < 1e-6f) {
+ if (o[a] < lo[a] || o[a] > hi[a]) miss = true;
+ continue;
+ }
+ float ta = (lo[a] - o[a]) / d[a], tb = (hi[a] - o[a]) / d[a];
+ if (ta > tb) {
+ float t = ta;
+ ta = tb, tb = t;
+ }
+ if (ta > t0) t0 = ta;
+ if (tb < t1) t1 = tb;
+ if (t0 > t1) miss = true;
+ }
+ if (!miss) best = t0, hit = e;
+ }
+ return hit;
+}
+
+bool mob_attack(const Entity *ce) {
+ Entity *e = (Entity *)ce;
+ Stack *h = held();
+ int k = item_kind(h->id);
+ float dmg = h->id >= 256 && k >= IK_PICKAXE && k <= IK_SWORD ? it_a[h->id - 256] : 1;
+ /* a critical hit: falling, not on a ladder or in water */
+ if (pl.vy < 0 && !pl.on_ground && !pl.in_water) dmg *= 1.5f;
+ float kx = e->x - pl.x, kz = e->z - pl.z;
+ if (pl.sprinting) e->vx += kx * 0.2f, e->vz += kz * 0.2f;
+ hurt(e, dmg, kx, kz);
+ if (pl.mode == 0) {
+ if (k == IK_SWORD) stack_wear(h, 1);
+ else if (k >= IK_PICKAXE && k <= IK_HOE) stack_wear(h, 2);
+ }
+ pl.exhaustion += 0.3f;
+ return true;
+}
+
+bool mob_use(Entity *e) {
+ Stack *h = held();
+ if (e->type == E_SHEEP && h->id == I_SHEARS && !e->sheared && e->state != 255) {
+ e->sheared = 1;
+ drop(B_WOOL_WHITE, 1 + rnd(3), e);
+ if (pl.mode == 0) stack_wear(h, 1);
+ return true;
+ }
+ if (e->type == E_COW && h->id == I_BUCKET) {
+ if (pl.mode == 1) return true;
+ if (h->aux <= 1) h->id = I_MILK_BUCKET, h->aux = 1;
+ else {
+ h->aux--;
+ if (inv_add(pl.inv, 36, I_MILK_BUCKET, 1, 0)) ent_drop(I_MILK_BUCKET, 1, 0, pl.x, pl.y + 1.3f, pl.z, true);
+ }
+ return true;
+ }
+ return false;
+}
+
+/* difficulty scales what mobs do to the player (EntityPlayer.attackEntityFrom) */
+static float scaled(float d) {
+ switch (opt.difficulty) {
+ case 0: return 0;
+ case 1: return d / 2 + 1 < d ? d / 2 + 1 : d;
+ case 3: return d * 1.5f;
+ }
+ return d;
+}
+
+static void push_player(float kx, float kz, float s) {
+ float d = sqrtf(kx * kx + kz * kz);
+ if (d <= 0) return;
+ pl.vx += kx / d * s;
+ pl.vz += kz / d * s;
+ pl.vy += 0.4f * (s / 0.4f);
+ if (pl.vy > 0.4f) pl.vy = 0.4f;
+}
+
+/* ---------------------------------------------------------------- explosions (Explosion, power 3) */
+static void explode(float x, float y, float z, float power) {
+ int r = (int)ceilf(power);
+ for (int dy = -r; dy <= r; dy++)
+ for (int dz = -r; dz <= r; dz++)
+ for (int dx = -r; dx <= r; dx++) {
+ float d = sqrtf((float)(dx * dx + dy * dy + dz * dz));
+ /* the blast fades with distance and randomly (0.7 to 1.3 of the power), blocks resist it */
+ float f = power * (0.7f + rndf() * 0.6f) - d * 0.9f;
+ int bx = ifl(x) + dx, by = ifl(y) + dy, bz = ifl(z) + dz;
+ int b = world_get(bx, by, bz);
+ if (b == B_AIR || blk_model[b] == M_LIQUID || blk_hard[b] == 255 || b == B_OBSIDIAN) continue;
+ float resist = blk_hard[b] / 20.0f * 5 / 5 + 0.3f; /* (blast resistance, about the hardness) */
+ if (f - resist * 0.3f <= 0) continue;
+ if (b == B_CHEST || b == B_FURNACE || b == B_FURNACE_LIT) tiles_removed(bx, by, bz);
+ world_set(bx, by, bz, B_AIR);
+ /* one in power of the blocks drop */
+ if (rnd((int)power) == 0) {
+ Stack out[2];
+ int n = block_drops(b, I_DIAMOND_PICKAXE, out);
+ for (int i = 0; i < n; i++) ent_drop(out[i].id, out[i].aux, 0, bx + 0.5f, by + 0.5f, bz + 0.5f, false);
+ }
+ }
+ /* the player: up to 2 x power blocks away, (impact^2 + impact) / 2 x 7 x 2 power + 1 */
+ float px = pl.x - x, py = pl.y + 0.9f - y, pz = pl.z - z;
+ float dist = sqrtf(px * px + py * py + pz * pz) / (power * 2);
+ if (dist <= 1) {
+ float impact = 1 - dist;
+ float dmg = (impact * impact + impact) / 2 * 7 * power * 2 + 1;
+ player_hurt(scaled(dmg), DMG_EXPLOSION);
+ push_player(px, pz, impact);
+ }
+ for (int i = 0; i < N_ENT; i++) {
+ Entity *e = &ents[i];
+ if (e->type < E_ZOMBIE || e->type > E_CHICKEN) continue;
+ float ex = e->x - x, ez = e->z - z, ey = e->y - y;
+ float d = sqrtf(ex * ex + ey * ey + ez * ez) / (power * 2);
+ if (d <= 1) hurt(e, ((1 - d) * (1 - d) + (1 - d)) / 2 * 7 * power * 2 + 1, ex, ez);
+ }
+}
+
+/* ---------------------------------------------------------------- arrows */
+static void shoot(const Entity *from) {
+ Entity *a = ent_new(E_ARROW, from->x, from->y + 1.5f, from->z);
+ if (!a) return;
+ a->item.id = I_ARROW;
+ float dx = pl.x - a->x, dy = pl.y + 0.6f - a->y, dz = pl.z - a->z;
+ float h = sqrtf(dx * dx + dz * dz);
+ dy += h * 0.2f; /* aimed a little up, to arc */
+ float d = sqrtf(dx * dx + dy * dy + dz * dz);
+ /* EntityArrow.setThrowableHeading: speed 1.6, spread 14 - difficulty x 4 */
+ float spread = (14 - opt.difficulty * 4) * 0.0075f;
+ a->vx = (dx / d + (rndf() - 0.5f) * 2 * spread) * 1.6f;
+ a->vy = (dy / d + (rndf() - 0.5f) * 2 * spread) * 1.6f;
+ a->vz = (dz / d + (rndf() - 0.5f) * 2 * spread) * 1.6f;
+ a->yaw = atan2f(-a->vx, a->vz) * 57.29578f;
+}
+
+static void arrow_tick(Entity *e) {
+ if (e->state) { /* stuck in a block */
+ if (++e->timer > 600) e->type = E_NONE;
+ return;
+ }
+ float nx = e->x + e->vx, ny = e->y + e->vy, nz = e->z + e->vz;
+ /* the player in its way? */
+ float px = pl.x - nx, pz = pl.z - nz;
+ if (!pl.dead && px * px + pz * pz < 0.5f && ny > pl.y && ny < pl.y + 1.8f) {
+ float sp = sqrtf(e->vx * e->vx + e->vy * e->vy + e->vz * e->vz);
+ player_hurt(scaled(ceilf(sp * 2.2f)), DMG_ARROW);
+ push_player(e->vx, e->vz, 0.4f);
+ e->type = E_NONE;
+ return;
+ }
+ int b = world_get(ifl(nx), ifl(ny), ifl(nz));
+ if (blk_flags[b] & BF_SOLID) {
+ e->state = 1;
+ e->vx = e->vy = e->vz = 0;
+ return;
+ }
+ e->x = nx, e->y = ny, e->z = nz;
+ bool water = blk_model[b] == M_LIQUID;
+ float drag = water ? 0.8f : 0.99f;
+ e->vx *= drag, e->vy *= drag, e->vz *= drag;
+ e->vy -= 0.05f;
+ if (++e->timer > 200) e->type = E_NONE;
+}
+
+/* ---------------------------------------------------------------- a tick */
+static float wrap(float a) {
+ while (a > 180) a -= 360;
+ while (a < -180) a += 360;
+ return a;
+}
+
+void mob_tick(Entity *e) {
+ if (e->type == E_ARROW) {
+ arrow_tick(e);
+ return;
+ }
+ const MobInfo *mi = &info[e->type];
+ if (e->hurt > 0) e->hurt--;
+ if (e->invuln > 0) e->invuln--;
+ if (e->state == 255) {
+ if (++e->timer >= 20) {
+ loot(e);
+ e->type = E_NONE;
+ }
+ e->vx *= 0.5f, e->vz *= 0.5f;
+ }
+ float dx = pl.x - e->x, dz = pl.z - e->z, dy = pl.y - e->y;
+ float dist = sqrtf(dx * dx + dz * dz);
+ /* far away: gone (EntityLiving.despawnEntity) */
+ if (hostile(e->type) && dist > 32) {
+ e->type = E_NONE;
+ return;
+ }
+ int bx = ifl(e->x), by = ifl(e->y), bz = ifl(e->z);
+ bool in_water = blk_model[world_get(bx, ifl(e->y + 0.4f), bz)] == M_LIQUID;
+ bool in_lava = world_get(bx, ifl(e->y + 0.4f), bz) == B_LAVA;
+ /* daylight burns zombies and skeletons (EntityZombie.onLivingUpdate) */
+ if ((e->type == E_ZOMBIE || e->type == E_SKELETON) && daylight() && !in_water &&
+ light_there(bx, ifl(e->y + 1.6f), bz) >= 15 && world_get(bx, ifl(e->y + 1.6f), bz) == B_AIR) {
+ 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 (e->fire > 0) {
+ if (e->fire % 20 == 0) hurt(e, 1, 0, 0);
+ e->fire--;
+ }
+ if (e->panic > 0) e->panic--;
+ if (e->delay > 0 && e->type != E_CREEPER) e->delay--;
+ /* where to go */
+ bool chase = false, go = false;
+ float speed = mi->speed;
+ if (e->state != 255 && hostile(e->type) && opt.difficulty > 0 && !pl.dead && pl.mode == 0 && dist < 16) {
+ chase = e->type != E_SPIDER || e->panic > 0 || light_there(bx, by + 1, bz) < 8 || !daylight();
+ }
+ if (chase) {
+ e->gx = pl.x, e->gz = pl.z;
+ go = true;
+ if (e->type == E_SKELETON && dist < 10) go = false;
+ if (e->type == E_CREEPER) {
+ if (dist < 3 && fabsf(dy) < 3) e->delay++, go = false;
+ else if (e->delay > 0 && dist > 7) e->delay--;
+ else if (e->delay > 0) e->delay++, go = dist > 2;
+ if (e->delay >= 30) {
+ e->type = E_NONE;
+ explode(e->x, e->y + 0.85f, e->z, opt.difficulty ? 3 : 0);
+ return;
+ }
+ }
+ } else if (e->state != 255) {
+ if (e->type == E_CREEPER && e->delay > 0) e->delay--;
+ if (e->panic > 0 && !hostile(e->type)) {
+ /* EntityAIPanic: run somewhere, fast */
+ if (e->panic % 20 == 19 || (e->gx == e->x && e->gz == e->z)) e->gx = e->x + rnd(11) - 5, e->gz = e->z + rnd(11) - 5;
+ go = true;
+ speed *= e->type == E_COW ? 2.0f : e->type == E_CHICKEN ? 1.4f : 1.25f;
+ } else {
+ /* EntityAIWander: now and then, somewhere within 10 blocks */
+ if (rnd(120) == 0) e->gx = e->x + rnd(21) - 10, e->gz = e->z + rnd(21) - 10;
+ float gx = e->gx - e->x, gz = e->gz - e->z;
+ go = gx * gx + gz * gz > 1;
+ }
+ }
+ if (go) {
+ float gx = e->gx - e->x, gz = e->gz - e->z;
+ if (gx * gx + gz * gz < 0.04f) go = false;
+ else {
+ float want = atan2f(-gx, gz) * 57.29578f;
+ float turn = wrap(want - e->yaw);
+ if (turn > 30) turn = 30;
+ if (turn < -30) turn = -30;
+ e->yaw += turn;
+ /* do not walk off a cliff or into lava (unless chasing down a step) */
+ float yr = e->yaw * 0.017453292f;
+ int ax = ifl(e->x - sinf(yr) * (mi->w / 2 + 0.4f)), az = ifl(e->z + cosf(yr) * (mi->w / 2 + 0.4f));
+ bool ground = false;
+ for (int k = 1; k <= 3 && !ground; k++) ground = (blk_flags[world_get(ax, by - k + 1, az)] & BF_SOLID) != 0;
+ int ahead = world_get(ax, by, az);
+ if ((!ground && !in_water) || ahead == B_LAVA || ahead == B_FLOWING_LAVA) go = false, e->gx = e->x, e->gz = e->z;
+ }
+ }
+ if (chase) {
+ float want = atan2f(-dx, dz) * 57.29578f;
+ float turn = wrap(want - e->yaw);
+ if (fabsf(turn) < 60) e->yaw += turn * 0.5f;
+ e->pitch = -atan2f(dy + 1.0f - mi->h * 0.85f, dist) * 57.29578f;
+ } else e->pitch *= 0.8f;
+ /* moving: EntityLivingBase.moveEntityWithHeading, the AI's speed twice (as forward and as friction) */
+ float fwd = go && e->state != 255 ? speed : 0;
+ float yr = e->yaw * 0.017453292f;
+ if (in_water) {
+ if (rndf() < 0.8f) e->vy += 0.04f; /* EntityAISwimming */
+ e->vx += -sinf(yr) * fwd * 0.02f / (fwd > 0 ? fwd : 1);
+ e->vz += cosf(yr) * fwd * 0.02f / (fwd > 0 ? fwd : 1);
+ } else {
+ float fr = e->on_ground ? 0.546f : 0.91f;
+ float f = e->on_ground ? fwd * (0.16277136f / (fr * fr * fr)) : 0.02f;
+ e->vx += -sinf(yr) * fwd * f;
+ e->vz += cosf(yr) * fwd * f;
+ }
+ float p[3] = {e->x, e->y, e->z}, v[3] = {e->vx, e->vy, e->vz};
+ float w = mi->w;
+ bool ground = phys_move(p, v, w, mi->h);
+ bool blocked = (v[0] != e->vx) || (v[2] != e->vz);
+ float moved = sqrtf((p[0] - e->x) * (p[0] - e->x) + (p[2] - e->z) * (p[2] - e->z));
+ e->x = p[0], e->y = p[1], e->z = p[2];
+ e->vx = v[0], e->vy = v[1], e->vz = v[2];
+ e->on_ground = ground;
+ if (blocked && go) {
+ if (e->type == E_SPIDER) e->vy = 0.2f; /* climbing */
+ else if (ground) e->vy = 0.42f;
+ }
+ if (in_water) e->vx *= 0.8f, e->vy *= 0.8f, e->vz *= 0.8f, e->vy -= 0.02f;
+ else {
+ e->vy -= 0.08f;
+ e->vy *= 0.98f;
+ float fr = ground ? 0.546f : 0.91f;
+ e->vx *= fr, e->vz *= fr;
+ if (e->type == E_CHICKEN && !ground && e->vy < 0) e->vy *= 0.6f; /* flapping */
+ }
+ /* the walk's swing (limbSwingAmount follows how fast it moves) */
+ float target = moved * 4;
+ if (target > 1) target = 1;
+ e->limb_amt += (target - e->limb_amt) * 0.4f;
+ e->limb += e->limb_amt;
+ if (e->state == 255 || e->type == E_CREEPER || e->type == E_SKELETON) {}
+ /* attacks */
+ if (chase && e->state != 255) {
+ float reach = mi->w * 2 * mi->w * 2 + 0.6f;
+ if ((e->type == E_ZOMBIE || e->type == E_SPIDER) && dist * dist < reach + 0.5f && fabsf(dy) < 1.5f && !e->delay) {
+ player_hurt(scaled(e->type == E_ZOMBIE ? 3 : 2), DMG_MOB);
+ push_player(dx, dz, 0.4f);
+ e->delay = 20;
+ }
+ /* a spider leaps (EntityAILeapAtTarget) */
+ if (e->type == E_SPIDER && ground && dist > 2 && dist < 4 && rnd(5) == 0) {
+ e->vx += dx / dist * 0.4f;
+ e->vz += dz / dist * 0.4f;
+ e->vy = 0.4f;
+ }
+ if (e->type == E_SKELETON && dist < 15 && !e->delay) {
+ shoot(e);
+ e->delay = (int16_t)(20 + dist / 15 * 40);
+ }
+ }
+ if (e->y < -64) e->type = E_NONE;
+}
diff --git a/games/numblocks/src/mob.h b/games/numblocks/src/mob.h
new file mode 100644
index 00000000..95ca6b32
--- /dev/null
+++ b/games/numblocks/src/mob.h
@@ -0,0 +1,22 @@
+/* The mobs' models: Minecraft 1.8's boxes (ModelBiped, ModelQuadruped and the
+ * others), in model pixels: y points down, the feet at y = 24, the face
+ * towards -z. Animated per frame by mob_parts (mob.c). */
+#ifndef NB_MOB_H
+#define NB_MOB_H
+#include "nb.h"
+
+typedef struct {
+ float x, y, z; /* the box's corner */
+ uint8_t w, h, d; /* its size */
+ uint8_t u, v; /* where its faces start in the skin */
+ uint8_t mirror, skin;
+ float px, py, pz; /* the point it turns about */
+ float rx, ry, rz; /* its turn (radians), Z then Y then X */
+ float grow; /* inflated by this much on every side (sheep's wool) */
+} Part;
+
+#define MAX_PARTS 12
+int mob_parts(const Entity *e, float pt, Part *out); /* this frame's parts */
+float mob_width(int type), mob_height(int type);
+float mob_scale(const Entity *e, float pt); /* a creeper swells before it blows */
+#endif
diff --git a/games/numblocks/src/nb.h b/games/numblocks/src/nb.h
index a01e987c..58b6e754 100644
--- a/games/numblocks/src/nb.h
+++ b/games/numblocks/src/nb.h
@@ -132,10 +132,14 @@ void player_add_xp(int n);
/* ---------------------------------------------------------------- entities (entity.c) */
enum { E_NONE, E_ITEM, E_ZOMBIE, E_SKELETON, E_CREEPER, E_SPIDER, E_PIG, E_COW, E_SHEEP, E_CHICKEN, E_ARROW };
typedef struct {
- uint8_t type, on_ground, hurt, state;
- int16_t age, health, timer, delay; /* delay: an item's pickup delay */
+ uint8_t type, on_ground, hurt, state; /* hurt: ticks of red; state 255: dying (timer counts) */
+ int16_t age, health, timer, delay; /* delay: an item's pickup delay, a mob's attack wait, a creeper's fuse */
float x, y, z, vx, vy, vz, yaw, pitch;
float px, py, pz; /* last tick's position */
+ float limb, limb_amt; /* the walk's swing */
+ float gx, gz; /* where it is going */
+ int16_t panic, fire;
+ uint8_t invuln, sheared;
Stack item;
} Entity;
#define N_ENT 24
@@ -143,6 +147,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 mob_tick(Entity *e);
+void mobs_spawn(void);
+bool mob_attack(const Entity *e); /* the player hits this mob (with the held item) */
+bool mob_use(Entity *e); /* the player uses the held item on it (shears, bucket) */
+Entity *entity_looked_at(float reach, float block_t); /* the mob under the crosshair, nearer than block_t */
+extern float tick_frac;
void player_respawn(void);
diff --git a/games/numblocks/src/player.c b/games/numblocks/src/player.c
index cc51b3f1..7183e64d 100644
--- a/games/numblocks/src/player.c
+++ b/games/numblocks/src/player.c
@@ -618,6 +618,19 @@ void player_tick(uint32_t keys, uint32_t pressed) {
if (pl.mode == 0) food_tick();
if (pl.dead) return;
pick();
+ /* a mob under the crosshair, nearer than the block: Back hits it, OK uses on it */
+ float bt = 1e9f;
+ if (pl.hit_face >= 0) {
+ float bx = pl.hit_x + 0.5f - pl.x, by = pl.hit_y + 0.5f - (pl.y + 1.62f), bz = pl.hit_z + 0.5f - pl.z;
+ bt = sqrtf(bx * bx + by * by + bz * bz) - 0.5f;
+ }
+ Entity *target = entity_looked_at(pl.mode ? 5.0f : 3.0f, bt);
+ if (target) {
+ if (pressed & K_ATTACK) mob_attack(target);
+ if ((pressed & K_USE) && mob_use(target)) pressed &= ~K_USE;
+ keys &= ~K_ATTACK;
+ pl.breaking = 0;
+ }
/* mining (Back held) */
if (break_cooldown) break_cooldown--;
if ((keys & K_ATTACK) && pl.hit_face >= 0 && !break_cooldown) {
diff --git a/games/numblocks/src/render.c b/games/numblocks/src/render.c
index 37fb8892..d641baee 100644
--- a/games/numblocks/src/render.c
+++ b/games/numblocks/src/render.c
@@ -14,6 +14,8 @@
#define SR 4 /* picture rows per strip (8 screen rows) */
static uint16_t strip[SCREEN_W * SR * 2];
+static uint16_t cbuf[SR][RW]; /* a strip of the picture */
+static float zbuf[SR][RW]; /* and how far each pixel's ray went (entities are hidden behind) */
/* per frame */
static float ox, oy, oz; /* camera, cache coordinates */
@@ -248,8 +250,15 @@ static inline uint16_t lit(int r, int g, int b, int face, int light, float dist)
/* what the last trace met: 1 a face of a whole block (cell hit_x, hit_y,
* hit_z, face hit_f), 2 the sky, 3 a plant (cell index hit_i), 0 anything else */
static int hit_kind, hit_x, hit_y, hit_z, hit_f, hit_i;
+static float last_t; /* where the last pixel's ray stopped (in lengths of its direction), 1e9 for the sky */
+static int brk_i = -1, brk_stage; /* the block being broken (cache index) and its crack stage */
+static inline int cracked(int tc, int i, int u, int v) {
+ if (i == brk_i && (cracks[brk_stage][(v * 16 + u) >> 3] >> (u & 7) & 1)) tc = shade565((uint16_t)tc, 13);
+ return tc;
+}
static uint16_t trace(float dx, float dy, float dz) {
hit_kind = 0;
+ last_t = 1e9f;
ST(st_pixels++);
float len = sqrtf(dx * dx + dy * dy + dz * dz);
int x = cam_x, y = cam_y, z = cam_z;
@@ -291,6 +300,8 @@ static uint16_t trace(float dx, float dy, float dz) {
int tc = texel565(b, blk_tex[b][f], u, v, col);
if (tc < 0 && m == M_LEAVES) tc = 0; /* Fast graphics: the holes are black */
if (tc >= 0) {
+ tc = cracked(tc, i, u, v);
+ last_t = t;
uint16_t c = lit565((uint16_t)tc, f, light_at(prev), t * len);
if (wa) c = pack((r5(c) * (256 - wa) + wr * wa) >> 8, (g6(c) * (256 - wa) + wg * wa) >> 8,
(b5(c) * (256 - wa) + wb * wa) >> 8);
@@ -303,6 +314,7 @@ static uint16_t trace(float dx, float dy, float dz) {
if (hit_cross(blk_tex[b][3], lx, ly, lz, dx, dy, dz, 0, t1, &h)) {
int r, g, bb;
texel_rgb(b, blk_tex[b][3], h.u, h.v, col, &r, &g, &bb);
+ last_t = t + h.t;
uint16_t c = lit(r, g, bb, 1, light_at(i), (t + h.t) * len);
if (wa) c = pack((r5(c) * (256 - wa) + wr * wa) >> 8, (g6(c) * (256 - wa) + wg * wa) >> 8,
(b5(c) * (256 - wa) + wb * wa) >> 8);
@@ -327,6 +339,7 @@ static uint16_t trace(float dx, float dy, float dz) {
}
if (wa) c = pack((r5(c) * (256 - wa) + wr * wa) >> 8, (g6(c) * (256 - wa) + wg * wa) >> 8,
(b5(c) * (256 - wa) + wb * wa) >> 8);
+ last_t = t + h.t;
return c;
}
}
@@ -455,6 +468,8 @@ static int face_pixel(float dx, float dy, float dz, int plane, int f) {
int tc = texel565(b, blk_tex[b][f], u, v, z * VCX + x);
if (tc < 0 && m == M_LEAVES) tc = 0;
if (tc < 0) return -1;
+ tc = cracked(tc, VC_I(x, y, z), u, v);
+ last_t = t;
float d2 = t * t * (dx * dx + dy * dy + dz * dz);
return lit565((uint16_t)tc, f, light, d2 > fog0 * fog0 ? sqrtf(d2) : 0);
}
@@ -465,6 +480,7 @@ typedef struct {
uint8_t kind, f;
int8_t plane; /* a face's plane: its coordinate along the face's axis */
uint16_t cell; /* a plant's cell */
+ float t;
} Sample;
static Sample rows[3][RW / 2 + 1];
@@ -479,6 +495,7 @@ static void sample_row(Sample *s, int py) {
int f = hit_f;
s[k].plane = (int8_t)((f >> 1) == 0 ? hit_y + (f & 1) : (f >> 1) == 1 ? hit_z + (f & 1) : hit_x + (f & 1));
s[k].cell = (uint16_t)hit_i;
+ s[k].t = last_t;
}
}
@@ -513,14 +530,354 @@ static uint16_t between(int px, int py, const Sample *a, const Sample *b, const
Hit h;
if (hit_cross(blk_tex[b][3], ox - x, oy - y, oz - z, dx, dy, dz, 0, 1e9f, &h)) {
int r, g, bb;
+ last_t = h.t;
texel_rgb(b, blk_tex[b][3], h.u, h.v, z * VCX + x, &r, &g, &bb);
return lit(r, g, bb, 1, light_at(i), h.t * sqrtf(dx * dx + dy * dy + dz * dz));
}
}
+ last_t = 1e9f;
if (agree && a->kind == 2) return ST(st_sky++), sky(dx, dy, dz, sqrtf(dx * dx + dy * dy + dz * dz));
return trace(dx, dy, dz);
}
+/* ---------------------------------------------------------------- entities
+ * Mobs are their models' boxes, each ray tested in the box's own frame and
+ * textured from the skin as Minecraft maps a box (ModelBox, TexturedQuad);
+ * dropped blocks are small spinning cubes, dropped items flat pictures facing
+ * the camera, as Fast graphics draws them. A pixel shows the nearest hit that
+ * is closer than the world behind it. */
+#include "mob.h"
+
+float tick_frac; /* how far between the last two ticks this frame is (main.c) */
+#define N_DRAW 12
+typedef struct {
+ const Entity *e;
+ int x0, y0, x1, y1; /* its rectangle on the picture (internal pixels) */
+ float ex, ey, ez; /* where it is (cache coordinates) */
+ int light;
+ float dist;
+} Draw;
+static Draw draws[N_DRAW];
+static int ndraws;
+
+static inline void ray_dir(int px, int py, float *d) {
+ float sv = (1 - 2 * (py + 0.5f) / RH) * TAN_V, su = (2 * (px + 0.5f) / RW - 1) * TAN_H;
+ d[0] = fwx + upx * sv + rgx * su;
+ d[1] = fwy + upy * sv;
+ d[2] = fwz + upz * sv + rgz * su;
+}
+
+/* a point (cache coordinates) on the picture; false if behind the camera */
+static bool project(float x, float y, float z, float *sx, float *sy) {
+ float rx = x - ox, ry = y - oy, rz = z - oz;
+ float cz = rx * fwx + ry * fwy + rz * fwz;
+ if (cz < 0.05f) return false;
+ float cx = rx * rgx + rz * rgz, cy = rx * upx + ry * upy + rz * upz;
+ *sx = (cx / cz / TAN_H + 1) * RW / 2;
+ *sy = (1 - cy / cz / TAN_V) * RH / 2;
+ return true;
+}
+
+static void ents_frame(void) {
+ ndraws = 0;
+ for (int i = 0; i < N_ENT && ndraws < N_DRAW; i++) {
+ const Entity *e = &ents[i];
+ if (e->type == E_NONE) continue;
+ float t = tick_frac;
+ float ex = e->px + (e->x - e->px) * t - vc_x0, ey = e->py + (e->y - e->py) * t - vc_y0,
+ ez = e->pz + (e->z - e->pz) * t - vc_z0;
+ float dx = ex - ox, dy = ey - oy, dz = ez - oz;
+ float dist = sqrtf(dx * dx + dy * dy + dz * dz);
+ if (dist > MAX_T + 1) continue;
+ float w, h;
+ if (e->type == E_ITEM) w = 0.5f, h = 0.6f;
+ else if (e->type == E_ARROW) w = 0.6f, h = 0.6f, ey -= 0.3f;
+ else w = mob_width(e->type) * 2.2f, h = mob_height(e->type) * 1.2f;
+ if (e->type >= E_ZOMBIE && e->type <= E_CHICKEN && e->state == 255) w = h = 2.4f; /* dying: lying down */
+ float sx0 = 1e9f, sy0 = 1e9f, sx1 = -1e9f, sy1 = -1e9f;
+ bool all = true;
+ for (int k = 0; k < 8; k++) {
+ float sx, sy;
+ if (!project(ex + ((k & 1) ? w : -w) / 2, ey + ((k & 2) ? h : 0), ez + ((k & 4) ? w : -w) / 2, &sx, &sy)) {
+ all = false;
+ break;
+ }
+ if (sx < sx0) sx0 = sx;
+ if (sx > sx1) sx1 = sx;
+ if (sy < sy0) sy0 = sy;
+ if (sy > sy1) sy1 = sy;
+ }
+ Draw *d = &draws[ndraws];
+ if (all) {
+ if (sx1 < 0 || sx0 >= RW || sy1 < 0 || sy0 >= RH) continue;
+ d->x0 = sx0 < 0 ? 0 : (int)sx0, d->x1 = sx1 >= RW ? RW : (int)sx1 + 1;
+ d->y0 = sy0 < 0 ? 0 : (int)sy0, d->y1 = sy1 >= RH ? RH : (int)sy1 + 1;
+ } else {
+ if (dist > 2.5f) continue; /* (behind the camera) */
+ d->x0 = 0, d->x1 = RW, d->y0 = 0, d->y1 = RH;
+ }
+ d->e = e, d->ex = ex, d->ey = ey, d->ez = ez, d->dist = dist;
+ int cx = (int)floorf(ex), cy = (int)floorf(ey + 0.2f), cz = (int)floorf(ez);
+ d->light = (unsigned)cx < VCX && (unsigned)cy < VCY && (unsigned)cz < VCZ ? light_at(VC_I(cx, cy, cz)) : 15;
+ ndraws++;
+ }
+}
+
+/* a part, ready to test: world (cache) to box frame */
+typedef struct {
+ float A[9], o[3]; /* box-frame ray: origin o, direction A d */
+ float x0, y0, z0, x1, y1, z1;
+ uint8_t u, v, w, h, d, mirror, skin;
+ uint8_t shade[6]; /* each face's shade (0..32) */
+} Box;
+
+static inline void mul3(const float *a, const float *b, float *o) { /* o = a b */
+ for (int r = 0; r < 3; r++)
+ for (int c = 0; c < 3; c++) o[r * 3 + c] = a[r * 3] * b[c] + a[r * 3 + 1] * b[3 + c] + a[r * 3 + 2] * b[6 + c];
+}
+static void rot(float *m, int axis, float a) { /* m = rotation about the axis */
+ float c = cosf(a), s = sinf(a);
+ for (int i = 0; i < 9; i++) m[i] = (i % 4 == 0);
+ int i = (axis + 1) % 3, j = (axis + 2) % 3;
+ m[i * 3 + i] = c, m[i * 3 + j] = -s, m[j * 3 + i] = s, m[j * 3 + j] = c;
+}
+
+/* M: model frame to world (Ry (180 - yaw) . death turn . S(-1,-1,1) . scale) */
+static int make_boxes(const Draw *dr, Box *bx) {
+ const Entity *e = dr->e;
+ Part parts[MAX_PARTS];
+ int n = mob_parts(e, tick_frac, parts);
+ float yaw = e->yaw * 0.017453292f;
+ float M[9], R[9], Z[9];
+ rot(R, 1, 3.14159265f - yaw);
+ /* dying: falls on its side over a second (RendererLivingEntity.rotateCorpse) */
+ float death = e->state == 255 ? (e->timer + tick_frac) / 20.0f * 1.6f : 0;
+ if (death > 0) {
+ death = sqrtf(death);
+ if (death > 1) death = 1;
+ }
+ rot(Z, 2, death * 1.5707963f);
+ mul3(R, Z, M);
+ float sc = mob_scale(e, tick_frac) / 16;
+ for (int i = 0; i < 9; i++) M[i] *= sc;
+ for (int i = 0; i < 9; i += 3) M[i + 1] = -M[i + 1], M[i] = -M[i]; /* S: x and y flipped */
+ float light_sh[6];
+ static const float face_shade[6] = {0.6f, 0.6f, 1.0f, 0.5f, 0.8f, 0.8f}; /* +x -x top bottom front back */
+ for (int p = 0; p < n; p++) {
+ const Part *pt = &parts[p];
+ float P[9], Ry[9], Rx[9], Rz[9], T[9];
+ rot(Rz, 2, pt->rz);
+ rot(Ry, 1, pt->ry);
+ rot(Rx, 0, pt->rx);
+ mul3(Rz, Ry, T);
+ mul3(T, Rx, P);
+ float W[9]; /* part frame to world */
+ mul3(M, P, W);
+ /* world = E + M (T0 + rp) + W v, T0 = (0, -24.125) model pixels: the feet on the ground */
+ float c[3] = {pt->px, pt->py - 24.125f, pt->pz};
+ float base[3];
+ for (int r = 0; r < 3; r++) base[r] = M[r * 3] * c[0] + M[r * 3 + 1] * c[1] + M[r * 3 + 2] * c[2];
+ base[0] += dr->ex, base[1] += dr->ey, base[2] += dr->ez;
+ /* the inverse of W: its transpose over its scale squared */
+ float k = 1 / (sc * sc);
+ Box *b = &bx[p];
+ for (int r = 0; r < 3; r++)
+ for (int q = 0; q < 3; q++) b->A[r * 3 + q] = W[q * 3 + r] * k;
+ float rel[3] = {ox - base[0], oy - base[1], oz - base[2]};
+ for (int r = 0; r < 3; r++) b->o[r] = b->A[r * 3] * rel[0] + b->A[r * 3 + 1] * rel[1] + b->A[r * 3 + 2] * rel[2];
+ b->x0 = pt->x - pt->grow, b->y0 = pt->y - pt->grow, b->z0 = pt->z - pt->grow;
+ b->x1 = pt->x + pt->w + pt->grow, b->y1 = pt->y + pt->h + pt->grow, b->z1 = pt->z + pt->d + pt->grow;
+ b->u = pt->u, b->v = pt->v, b->w = pt->w, b->h = pt->h, b->d = pt->d, b->mirror = pt->mirror, b->skin = pt->skin;
+ /* each face lit by how it faces in the world (like blocks: up 1.0, down 0.5, sides 0.8 and 0.6) */
+ for (int f = 0; f < 6; f++) {
+ int ax = f < 2 ? 0 : f < 4 ? 1 : 2;
+ float sgn = (f & 1) ? -1.0f : 1.0f;
+ if (ax == 1) sgn = -sgn; /* model y is down: face 2 (y0) points up */
+ float nx = W[ax] * sgn / sc, ny = W[3 + ax] * sgn / sc, nz = W[6 + ax] * sgn / sc;
+ float sh = ny > 0.7f ? 1.0f : ny < -0.7f ? 0.5f : fabsf(nz) > fabsf(nx) ? 0.8f : 0.6f;
+ (void)face_shade;
+ light_sh[f] = sh;
+ b->shade[f] = (uint8_t)(shade[0][dr->light] * sh + 0.5f);
+ }
+ }
+ (void)light_sh;
+ return n;
+}
+
+/* the skin texel the ray meets on a box face (ModelBox's layout), -1 if see-through */
+static int box_texel(const Box *b, int face, float x, float y, float z) {
+ if (b->mirror) {
+ x = b->x0 + b->x1 - x;
+ if (face < 2) face ^= 1;
+ }
+ /* pixel coordinates inside the box (the inflation of wool keeps the layout) */
+ float sx = (b->x1 - b->x0) / b->w, sy = (b->y1 - b->y0) / b->h, sz = (b->z1 - b->z0) / b->d;
+ int lx = (int)((x - b->x0) / sx), ly = (int)((y - b->y0) / sy), lz = (int)((z - b->z0) / sz);
+ if (lx >= b->w) lx = b->w - 1;
+ if (ly >= b->h) ly = b->h - 1;
+ if (lz >= b->d) lz = b->d - 1;
+ if (lx < 0) lx = 0;
+ if (ly < 0) ly = 0;
+ if (lz < 0) lz = 0;
+ int U = b->u, V = b->v, w = b->w, d = b->d, u, v;
+ switch (face) {
+ case 0: u = U + d + w + lz, v = V + d + ly; break; /* +x */
+ case 1: u = U + (d - 1 - lz), v = V + d + ly; break; /* -x */
+ case 2: u = U + d + lx, v = V + (d - 1 - lz); break; /* y0 (the top) */
+ case 3: u = U + d + w + lx, v = V + d - 1 - lz; break; /* y1 (the bottom) */
+ case 4: u = U + d + lx, v = V + d + ly; break; /* z0 (the front) */
+ default: u = U + d + w + d + (w - 1 - lx), v = V + d + ly; break; /* z1 (the back) */
+ }
+ if ((unsigned)u >= 64 || (unsigned)v >= 32) return -1;
+ uint8_t p = skin_px[b->skin][(v * 64 + u) >> 1];
+ int i = (u & 1) ? p >> 4 : p & 15;
+ return i ? skin_pal[b->skin][i] : -1;
+}
+
+/* the nearest box the ray meets (t > 0), its colour; false if none */
+static bool boxes_hit(const Box *bx, int n, const float *d, float *best_t, uint16_t *col) {
+ bool any = false;
+ for (int p = 0; p < n; p++) {
+ const Box *b = &bx[p];
+ float dl[3];
+ for (int r = 0; r < 3; r++) dl[r] = b->A[r * 3] * d[0] + b->A[r * 3 + 1] * d[1] + b->A[r * 3 + 2] * d[2];
+ float t0 = 0, t1 = *best_t;
+ int f0 = -1;
+ const float lo[3] = {b->x0, b->y0, b->z0}, hi[3] = {b->x1, b->y1, b->z1};
+ bool miss = false;
+ for (int a = 0; a < 3 && !miss; a++) {
+ if (fabsf(dl[a]) < 1e-9f) {
+ if (b->o[a] < lo[a] || b->o[a] > hi[a]) miss = true;
+ continue;
+ }
+ float inv = 1 / dl[a];
+ float ta = (lo[a] - b->o[a]) * inv, tb = (hi[a] - b->o[a]) * inv;
+ int fa = a * 2 + 1, fb = a * 2; /* entering through the low side: -x (1), y0 (2)... */
+ if (a == 1) fa = 2, fb = 3;
+ if (a == 2) fa = 4, fb = 5;
+ if (ta > tb) {
+ float t = ta;
+ ta = tb, tb = t;
+ int f = fa;
+ fa = fb, fb = f;
+ }
+ if (ta > t0) t0 = ta, f0 = fa;
+ if (tb < t1) t1 = tb;
+ if (t0 > t1) miss = true;
+ }
+ if (miss || f0 < 0) continue;
+ float hx = b->o[0] + dl[0] * t0, hy = b->o[1] + dl[1] * t0, hz = b->o[2] + dl[2] * t0;
+ int c = box_texel(b, f0, hx, hy, hz);
+ if (c < 0) continue; /* (see-through: the ray is not followed further in this box) */
+ *best_t = t0;
+ *col = shade565((uint16_t)c, b->shade[f0]);
+ any = true;
+ }
+ return any;
+}
+
+/* a dropped item: a small cube of its block, or its picture */
+static bool item_hit(const Draw *dr, const float *d, float *best_t, uint16_t *col) {
+ const Entity *e = dr->e;
+ int id = e->item.id;
+ float age = e->age + tick_frac;
+ float bob = sinf(age / 10.0f + e->yaw) * 0.1f + 0.1f;
+ bool cube = id < 256 && (blk_model[id] == M_CUBE || blk_model[id] == M_LEAVES || blk_model[id] == M_GLASS ||
+ blk_model[id] == M_SLAB);
+ float cx = dr->ex, cy = dr->ey + bob + 0.125f, cz = dr->ez;
+ if (cube) {
+ /* EntityItem render: a quarter block, turning */
+ float a = age / 20.0f + e->yaw, ca = cosf(a), sa = sinf(a);
+ float rel[3] = {ox - cx, oy - cy, oz - cz};
+ float o[3] = {ca * rel[0] + sa * rel[2], rel[1], -sa * rel[0] + ca * rel[2]};
+ float dl[3] = {ca * d[0] + sa * d[2], d[1], -sa * d[0] + ca * d[2]};
+ const float hs = 0.125f;
+ float t0 = 0, t1 = *best_t;
+ int f0 = -1;
+ for (int k = 0; k < 3; k++) {
+ if (fabsf(dl[k]) < 1e-9f) {
+ if (fabsf(o[k]) > hs) return false;
+ continue;
+ }
+ float ta = (-hs - o[k]) / dl[k], tb = (hs - o[k]) / dl[k];
+ static const int8_t lowf[3] = {4, 0, 2}; /* block faces: -x 4, -y 0, -z 2 */
+ int fa = lowf[k], fb = lowf[k] + 1;
+ if (ta > tb) {
+ float t = ta;
+ ta = tb, tb = t;
+ int f = fa;
+ fa = fb, fb = f;
+ }
+ if (ta > t0) t0 = ta, f0 = fa;
+ if (tb < t1) t1 = tb;
+ if (t0 > t1) return false;
+ }
+ if (f0 < 0) return false;
+ float hx = o[0] + dl[0] * t0 + hs, hy = o[1] + dl[1] * t0 + hs, hz = o[2] + dl[2] * t0 + hs;
+ int u, v;
+ float k4 = 16 / (2 * hs);
+ switch (f0) {
+ case 0: case 1: u = (int)(hx * k4); v = (int)(hz * k4); break;
+ case 2: case 3: u = (int)(hx * k4); v = 15 - (int)(hy * k4); break;
+ default: u = (int)(hz * k4); v = 15 - (int)(hy * k4); break;
+ }
+ u &= 15, v &= 15;
+ int tc = texel565(id, blk_tex[id][f0], u, v, 0);
+ if (tc < 0) tc = 0;
+ *best_t = t0;
+ *col = lit565((uint16_t)tc, f0, dr->light, t0 * sqrtf(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]));
+ return true;
+ }
+ /* a flat picture half a block wide, facing the camera */
+ int ic = item_icon(id);
+ if (ic < 0) return false;
+ float rel[3] = {cx - ox, cy + 0.125f - oy, cz - oz};
+ float den = d[0] * fwx + d[1] * fwy + d[2] * fwz;
+ float t = (rel[0] * fwx + rel[1] * fwy + rel[2] * fwz) / den;
+ if (!(t > 0) || t >= *best_t) return false;
+ float hx = d[0] * t - rel[0], hy = d[1] * t - rel[1], hz = d[2] * t - rel[2];
+ float u = (hx * rgx + hz * rgz) / 0.5f + 0.5f, v = 0.5f - (hx * upx + hy * upy + hz * upz) / 0.5f;
+ if (u < 0 || u >= 1 || v < 0 || v >= 1) return false;
+ int w = spr_w[ic], hh = spr_h[ic], pxu = (int)(u * w), pyv = (int)(v * hh);
+ const uint8_t *px = spr_px + spr_off[ic] + pyv * ((w + 1) / 2);
+ int i = (pxu & 1) ? px[pxu >> 1] >> 4 : px[pxu >> 1] & 15;
+ if (!i) return false;
+ *best_t = t;
+ *col = lit565(spr_pal[ic][i], 1, dr->light, t * sqrtf(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]));
+ return true;
+}
+
+static void ents_strip(int py0, int rows, uint16_t (*cb)[RW], float (*zb)[RW]) {
+ Box bx[MAX_PARTS];
+ for (int k = 0; k < ndraws; k++) {
+ const Draw *dr = &draws[k];
+ if (dr->y1 <= py0 || dr->y0 >= py0 + rows) continue;
+ const Entity *e = dr->e;
+ bool mob = e->type >= E_ZOMBIE && e->type <= E_CHICKEN;
+ int n = mob ? make_boxes(dr, bx) : 0;
+ /* hurt (and dying): a red tint; a creeper about to blow flashes white */
+ int red = mob && (e->hurt > 0 || e->state == 255) ? 10 : 0;
+ int white = e->type == E_CREEPER && e->delay > 0 && ((e->delay / 3) & 1) ? 16 : 0;
+ for (int py = py0 > dr->y0 ? py0 : dr->y0; py < dr->y1 && py < py0 + rows; py++)
+ for (int px = dr->x0; px < dr->x1; px++) {
+ float d[3];
+ ray_dir(px, py, d);
+ float t = zb[py - py0][px];
+ uint16_t c;
+ bool hit = mob ? boxes_hit(bx, n, d, &t, &c) : item_hit(dr, d, &t, &c);
+ if (!hit) continue;
+ if (mob) {
+ if (red) c = mix565(c, 0xF800, red);
+ if (white) c = mix565(c, 0xFFFF, white);
+ float dist = t * sqrtf(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
+ if (dist > fog0) c = mix565(c, fog565, dist >= fog1 ? 32 : (int)((dist - fog0) * fog_k * 32));
+ }
+ cb[py - py0][px] = c;
+ zb[py - py0][px] = t;
+ }
+ }
+}
+
/* ---------------------------------------------------------------- the frame */
static void setup_light(float sun) {
/* Minecraft's light table (gamma "Moody"): (1 - f) / (3f + 1), f = 1 - level / 15,
@@ -622,6 +979,14 @@ void render_frame(const Camera *c, uint32_t tod) {
fog565 = pack(fog_r, fog_g, fog_b);
cloud_off = (tod % 24000) * 0.03f;
+ /* the block being broken */
+ brk_i = -1;
+ if (pl.breaking > 0 && pl.hit_face >= 0 && world_loaded(pl.hit_x, pl.hit_y, pl.hit_z)) {
+ brk_i = VC_I(pl.hit_x - vc_x0, pl.hit_y - vc_y0, pl.hit_z - vc_z0);
+ brk_stage = (int)(pl.breaking * 10);
+ if (brk_stage > 9) brk_stage = 9;
+ }
+ ents_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];
@@ -630,24 +995,31 @@ void render_frame(const Camera *c, uint32_t tod) {
for (int r = 0; r < SR; r += 2) {
int y = py + r;
sample_row(bot, y + 2);
- uint16_t *row0 = strip + (r * 2) * SCREEN_W, *row1 = strip + (r * 2 + 2) * SCREEN_W;
+ uint16_t *c0 = cbuf[r], *c1 = cbuf[r + 1];
+ float *z0 = zbuf[r], *z1 = zbuf[r + 1];
for (int k = 0; k < RW / 2; k++) {
int x = 2 * k;
- uint16_t c00 = top[k].c;
- uint16_t c10 = between(x + 1, y, &top[k], &top[k + 1], NULL, NULL);
- uint16_t c01 = between(x, y + 1, &top[k], &bot[k], NULL, NULL);
- uint16_t c11 = between(x + 1, y + 1, &top[k], &top[k + 1], &bot[k], &bot[k + 1]);
- row0[x * 2] = row0[x * 2 + 1] = c00;
- row0[x * 2 + 2] = row0[x * 2 + 3] = c10;
- row1[x * 2] = row1[x * 2 + 1] = c01;
- row1[x * 2 + 2] = row1[x * 2 + 3] = c11;
+ c0[x] = top[k].c;
+ z0[x] = top[k].t;
+ c0[x + 1] = between(x + 1, y, &top[k], &top[k + 1], NULL, NULL);
+ z0[x + 1] = last_t;
+ c1[x] = between(x, y + 1, &top[k], &bot[k], NULL, NULL);
+ z1[x] = last_t;
+ c1[x + 1] = between(x + 1, y + 1, &top[k], &top[k + 1], &bot[k], &bot[k + 1]);
+ z1[x + 1] = last_t;
}
- memcpy(row0 + SCREEN_W, row0, SCREEN_W * 2);
- memcpy(row1 + SCREEN_W, row1, SCREEN_W * 2);
Sample *t = top;
top = bot;
bot = t;
}
+ ents_strip(py, SR, cbuf, zbuf);
+ /* 2 x 2 screen pixels each */
+ for (int r = 0; r < SR; r++) {
+ uint16_t *d = strip + r * 2 * SCREEN_W;
+ const uint16_t *c = cbuf[r];
+ for (int x = 0; x < RW; x++) d[2 * x] = d[2 * x + 1] = c[x];
+ memcpy(d + SCREEN_W, d, SCREEN_W * 2);
+ }
hud_strip(strip, py * 2, SR * 2);
plat_push(0, py * 2, SCREEN_W, SR * 2, strip);
}
diff --git a/games/numblocks/tests/gen/ref_terrain.h b/games/numblocks/tests/gen/ref_terrain.h
index 7621b939..47bab359 100644
--- a/games/numblocks/tests/gen/ref_terrain.h
+++ b/games/numblocks/tests/gen/ref_terrain.h
@@ -273,3 +273,129 @@ static void ref_chunk(int cx, int cz, uint8_t *chunk) {
r_b(chunk, bb, &rr, ii, jj, d0, ak, al);
}
}
+
+/* ---- literal caves/canyons (double, recursive) on a [y][z][x] chunk ---- */
+static float r_sintab[65536];
+static void r_sin_init(void) { for (int i = 0; i < 65536; i++) r_sintab[i] = (float)sin((double)i * 3.141592653589793 * 2.0 / 65536.0); }
+static float r_sin(float f) { return r_sintab[(int)(f * 10430.378F) & 65535]; }
+static float r_cos(float f) { return r_sintab[(int)(f * 10430.378F + 16384.0F) & 65535]; }
+static uint8_t *rc_chunk; static const uint8_t *rc_b16; static float rc_d[1024];
+static int r_floor(double d) { int i = (int)d; return d < (double)i ? i - 1 : i; }
+static void rcave_a(long long i, int j, int k, double d0, double d1, double d2, float f, float f1, float f2, int l, int i1, double d3) {
+ uint8_t *chunk = rc_chunk;
+ double d4 = (double)(j * 16 + 8), d5 = (double)(k * 16 + 8); float f3 = 0, f4 = 0; JRand random; jr_seed(&random, i);
+ if (i1 <= 0) { int j1 = 8 * 16 - 16; i1 = j1 - jr_int(&random, j1 / 4); }
+ int flag = 0; if (l == -1) { l = i1 / 2; flag = 1; }
+ int k1 = jr_int(&random, i1 / 2) + i1 / 4;
+ for (int flag1 = jr_int(&random, 6) == 0; l < i1; ++l) {
+ double d6 = 1.5 + (double)(r_sin((float)l * 3.1415927F / (float)i1) * f * 1.0F), d7 = d6 * d3;
+ float f5 = r_cos(f2), f6 = r_sin(f2);
+ d0 += (double)(r_cos(f1) * f5); d1 += (double)f6; d2 += (double)(r_sin(f1) * f5);
+ if (flag1) f2 *= 0.92F; else f2 *= 0.7F;
+ f2 += f4 * 0.1F; f1 += f3 * 0.1F; f4 *= 0.9F; f3 *= 0.75F;
+ { float a = jr_float(&random), b = jr_float(&random), c = jr_float(&random); f4 += (a - b) * c * 2.0F; }
+ { float a = jr_float(&random), b = jr_float(&random), c = jr_float(&random); f3 += (a - b) * c * 4.0F; }
+ if (!flag && l == k1 && f > 1.0F && i1 > 0) {
+ long long s1 = jr_long(&random); float w1 = jr_float(&random) * 0.5F + 0.5F;
+ rcave_a(s1, j, k, d0, d1, d2, w1, f1 - 1.5707964F, f2 / 3.0F, l, i1, 1.0);
+ long long s2 = jr_long(&random); float w2 = jr_float(&random) * 0.5F + 0.5F;
+ rcave_a(s2, j, k, d0, d1, d2, w2, f1 + 1.5707964F, f2 / 3.0F, l, i1, 1.0);
+ return;
+ }
+ if (flag || jr_int(&random, 4) != 0) {
+ double d8 = d0 - d4, d9 = d2 - d5, d10 = (double)(i1 - l), d11 = (double)(f + 2.0F + 16.0F);
+ if (d8 * d8 + d9 * d9 - d10 * d10 > d11 * d11) return;
+ if (d0 >= d4 - 16.0 - d6 * 2.0 && d2 >= d5 - 16.0 - d6 * 2.0 && d0 <= d4 + 16.0 + d6 * 2.0 && d2 <= d5 + 16.0 + d6 * 2.0) {
+ int l1 = r_floor(d0 - d6) - j * 16 - 1, i2 = r_floor(d0 + d6) - j * 16 + 1, j2 = r_floor(d1 - d7) - 1, k2 = r_floor(d1 + d7) + 1, l2 = r_floor(d2 - d6) - k * 16 - 1, i3 = r_floor(d2 + d6) - k * 16 + 1;
+ if (l1 < 0) l1 = 0; if (i2 > 16) i2 = 16; if (j2 < 1) j2 = 1; if (k2 > 248) k2 = 248; if (l2 < 0) l2 = 0; if (i3 > 16) i3 = 16;
+ int flag2 = 0;
+ for (int k3 = l1; !flag2 && k3 < i2; ++k3) for (int j3 = l2; !flag2 && j3 < i3; ++j3) for (int l3 = k2 + 1; !flag2 && l3 >= j2 - 1; --l3) if (l3 >= 0 && l3 < 256) {
+ int b = RS(k3, l3, j3); if (b == B_WATER || b == B_FLOWING_WATER) flag2 = 1;
+ if (l3 != j2 - 1 && k3 != l1 && k3 != i2 - 1 && j3 != l2 && j3 != i3 - 1) l3 = j2; }
+ if (!flag2) {
+ for (int j3 = l1; j3 < i2; ++j3) { double d12 = ((double)(j3 + j * 16) + 0.5 - d0) / d6;
+ for (int i4 = l2; i4 < i3; ++i4) { double d13 = ((double)(i4 + k * 16) + 0.5 - d2) / d6; int flag3 = 0;
+ if (d12 * d12 + d13 * d13 < 1.0) for (int j4 = k2; j4 > j2; --j4) { double d14 = ((double)(j4 - 1) + 0.5 - d1) / d7;
+ if (d14 > -0.7 && d12 * d12 + d14 * d14 + d13 * d13 < 1.0) {
+ int b1 = RS(j3, j4, i4), b2 = j4 + 1 < 256 ? RS(j3, j4 + 1, i4) : B_AIR;
+ if (b1 == B_GRASS || b1 == B_MYCELIUM) flag3 = 1;
+ int carv = b1 == B_STONE || b1 == B_DIRT || b1 == B_COARSE_DIRT || b1 == B_PODZOL || b1 == B_GRASS || IS_CLAY(b1) || b1 == B_SANDSTONE || b1 == B_RED_SANDSTONE || b1 == B_MYCELIUM || b1 == B_SNOW_LAYER || ((b1 == B_SAND || b1 == B_RED_SAND || b1 == B_GRAVEL) && !(b2 == B_WATER || b2 == B_FLOWING_WATER));
+ if (carv) {
+ if (j4 - 1 < 10) RS(j3, j4, i4) = B_LAVA;
+ else { RS(j3, j4, i4) = B_AIR; if (b2 == B_SAND) RS(j3, j4 + 1, i4) = B_SANDSTONE; else if (b2 == B_RED_SAND) RS(j3, j4 + 1, i4) = B_RED_SANDSTONE;
+ int bd = RS(j3, j4 - 1, i4);
+ if (flag3 && (bd == B_DIRT || bd == B_COARSE_DIRT || bd == B_PODZOL)) { int t = bio(rc_b16[j3 + i4 * 16])->top; if (t == B_PODZOL || t == B_COARSE_DIRT) t = B_DIRT; RS(j3, j4 - 1, i4) = t; } }
+ } } } } }
+ if (flag) break;
+ }
+ }
+ }
+ }
+}
+static void rcanyon_a(long long i, int j, int k, double d0, double d1, double d2, float f, float f1, float f2, int l, int i1, double d3) {
+ uint8_t *chunk = rc_chunk;
+ JRand random; jr_seed(&random, i); double d4 = (double)(j * 16 + 8), d5 = (double)(k * 16 + 8); float f3 = 0, f4 = 0;
+ if (i1 <= 0) { int j1 = 8 * 16 - 16; i1 = j1 - jr_int(&random, j1 / 4); }
+ int flag = 0; if (l == -1) { l = i1 / 2; flag = 1; }
+ float f5 = 1.0F;
+ for (int k1 = 0; k1 < 256; ++k1) { if (k1 == 0 || jr_int(&random, 3) == 0) { float a = jr_float(&random), b = jr_float(&random); f5 = 1.0F + a * b * 1.0F; } rc_d[k1] = f5 * f5; }
+ for (; l < i1; ++l) {
+ double d6 = 1.5 + (double)(r_sin((float)l * 3.1415927F / (float)i1) * f * 1.0F), d7 = d6 * d3;
+ d6 *= (double)jr_float(&random) * 0.25 + 0.75; d7 *= (double)jr_float(&random) * 0.25 + 0.75;
+ float f6 = r_cos(f2), f7 = r_sin(f2);
+ d0 += (double)(r_cos(f1) * f6); d1 += (double)f7; d2 += (double)(r_sin(f1) * f6);
+ f2 *= 0.7F; f2 += f4 * 0.05F; f1 += f3 * 0.05F; f4 *= 0.8F; f3 *= 0.5F;
+ { float a = jr_float(&random), b = jr_float(&random), c = jr_float(&random); f4 += (a - b) * c * 2.0F; }
+ { float a = jr_float(&random), b = jr_float(&random), c = jr_float(&random); f3 += (a - b) * c * 4.0F; }
+ if (flag || jr_int(&random, 4) != 0) {
+ double d8 = d0 - d4, d9 = d2 - d5, d10 = (double)(i1 - l), d11 = (double)(f + 2.0F + 16.0F);
+ if (d8 * d8 + d9 * d9 - d10 * d10 > d11 * d11) return;
+ if (d0 >= d4 - 16.0 - d6 * 2.0 && d2 >= d5 - 16.0 - d6 * 2.0 && d0 <= d4 + 16.0 + d6 * 2.0 && d2 <= d5 + 16.0 + d6 * 2.0) {
+ int l1 = r_floor(d0 - d6) - j * 16 - 1, i2 = r_floor(d0 + d6) - j * 16 + 1, j2 = r_floor(d1 - d7) - 1, k2 = r_floor(d1 + d7) + 1, l2 = r_floor(d2 - d6) - k * 16 - 1, i3 = r_floor(d2 + d6) - k * 16 + 1;
+ if (l1 < 0) l1 = 0; if (i2 > 16) i2 = 16; if (j2 < 1) j2 = 1; if (k2 > 248) k2 = 248; if (l2 < 0) l2 = 0; if (i3 > 16) i3 = 16;
+ int flag1 = 0;
+ for (int k3 = l1; !flag1 && k3 < i2; ++k3) for (int j3 = l2; !flag1 && j3 < i3; ++j3) for (int l3 = k2 + 1; !flag1 && l3 >= j2 - 1; --l3) if (l3 >= 0 && l3 < 256) {
+ int b = RS(k3, l3, j3); if (b == B_WATER || b == B_FLOWING_WATER) flag1 = 1;
+ if (l3 != j2 - 1 && k3 != l1 && k3 != i2 - 1 && j3 != l2 && j3 != i3 - 1) l3 = j2; }
+ if (!flag1) {
+ for (int j3 = l1; j3 < i2; ++j3) { double d12 = ((double)(j3 + j * 16) + 0.5 - d0) / d6;
+ for (int i4 = l2; i4 < i3; ++i4) { double d13 = ((double)(i4 + k * 16) + 0.5 - d2) / d6; int flag2 = 0;
+ if (d12 * d12 + d13 * d13 < 1.0) for (int j4 = k2; j4 > j2; --j4) { double d14 = ((double)(j4 - 1) + 0.5 - d1) / d7;
+ if ((d12 * d12 + d13 * d13) * (double)rc_d[j4 - 1] + d14 * d14 / 6.0 < 1.0) {
+ int b1 = RS(j3, j4, i4); if (b1 == B_GRASS) flag2 = 1;
+ if (b1 == B_STONE || b1 == B_DIRT || b1 == B_COARSE_DIRT || b1 == B_PODZOL || b1 == B_GRASS) {
+ if (j4 - 1 < 10) RS(j3, j4, i4) = B_LAVA;
+ else { RS(j3, j4, i4) = B_AIR; int bd = RS(j3, j4 - 1, i4); if (flag2 && (bd == B_DIRT || bd == B_COARSE_DIRT || bd == B_PODZOL)) RS(j3, j4 - 1, i4) = bio(rc_b16[j3 + i4 * 16])->top; }
+ } } } } }
+ if (flag) break;
+ }
+ }
+ }
+ }
+}
+static void ref_caves(int i, int j, uint8_t *chunk, const uint8_t *b16) {
+ rc_chunk = chunk; rc_b16 = b16;
+ JRand b; jr_seed(&b, g_seed); long long l = jr_long(&b), i1 = jr_long(&b);
+ for (int pass = 0; pass < 2; pass++)
+ for (int j1 = i - 8; j1 <= i + 8; ++j1) for (int k1 = j - 8; k1 <= j + 8; ++k1) {
+ long long l1 = (long long)((unsigned long long)(long long)j1 * (unsigned long long)l), i2 = (long long)((unsigned long long)(long long)k1 * (unsigned long long)i1);
+ jr_seed(&b, l1 ^ i2 ^ g_seed);
+ if (pass == 0) {
+ int n = jr_int(&b, jr_int(&b, jr_int(&b, 15) + 1) + 1); if (jr_int(&b, 7) != 0) n = 0;
+ for (int c = 0; c < n; ++c) {
+ double d0 = (double)(j1 * 16 + jr_int(&b, 16)), d1 = (double)jr_int(&b, jr_int(&b, 120) + 8), d2 = (double)(k1 * 16 + jr_int(&b, 16));
+ int kk = 1;
+ if (jr_int(&b, 4) == 0) { long long s = jr_long(&b); float w = 1.0F + jr_float(&b) * 6.0F; rcave_a(s, i, j, d0, d1, d2, w, 0, 0, -1, -1, 0.5); kk += jr_int(&b, 4); }
+ for (int l1b = 0; l1b < kk; ++l1b) {
+ float f = jr_float(&b) * 3.1415927F * 2.0F, f1 = (jr_float(&b) - 0.5F) * 2.0F / 8.0F, f2 = jr_float(&b) * 2.0F + jr_float(&b);
+ if (jr_int(&b, 10) == 0) { float a = jr_float(&b), c2 = jr_float(&b); f2 *= a * c2 * 3.0F + 1.0F; }
+ rcave_a(jr_long(&b), i, j, d0, d1, d2, f2, f, f1, 0, 0, 1.0);
+ }
+ }
+ } else if (jr_int(&b, 50) == 0) {
+ double d0 = (double)(j1 * 16 + jr_int(&b, 16)), d1 = (double)(jr_int(&b, jr_int(&b, 40) + 8) + 20), d2 = (double)(k1 * 16 + jr_int(&b, 16));
+ float f = jr_float(&b) * 3.1415927F * 2.0F, f1 = (jr_float(&b) - 0.5F) * 2.0F / 8.0F, f2 = (jr_float(&b) * 2.0F + jr_float(&b)) * 2.0F;
+ rcanyon_a(jr_long(&b), i, j, d0, d1, d2, f2, f, f1, 0, 0, 3.0);
+ }
+ }
+}
diff --git a/games/numblocks/tests/gen/t_cavecmp.c b/games/numblocks/tests/gen/t_cavecmp.c
new file mode 100644
index 00000000..9cbe0ea1
--- /dev/null
+++ b/games/numblocks/tests/gen/t_cavecmp.c
@@ -0,0 +1,35 @@
+#include "../../src/gen.c"
+#include <stdio.h>
+#include <stdlib.h>
+#include "ref_terrain.h"
+#include "t_init.h"
+static ColSum csum[256];
+int main(int argc, char **argv) {
+ i64 seed = argc > 1 ? strtoll(argv[1], 0, 10) : 12345;
+ int n = argc > 2 ? atoi(argv[2]) : 50;
+ test_init(seed); ref_init(seed); r_sin_init(); bflags_init();
+ { JRand r; jr_seed(&r, seed); cave_mul_x = jr_long(&r); cave_mul_z = jr_long(&r); }
+ static uint8_t ref[65536], mine[65536];
+ long diff = 0, tot = 0, cdiff = 0, carved = 0;
+ JRand pick; jr_seed(&pick, 7);
+ for (int c = 0; c < n; c++) {
+ int cx = jr_int(&pick, 2000) - 1000, cz = jr_int(&pick, 2000) - 1000;
+ ref_chunk(cx, cz, ref);
+ uint8_t b16[256]; memcpy(b16, cb16, 256);
+ ref_caves(cx, cz, ref, b16);
+ chunk_terrain(cx, cz, mine, 0, 256, csum);
+ memcpy(c_b16, b16, 256);
+ CaveCtx ctx = {0}; ctx.mode = CAVE_OUT; ctx.tcx = cx; ctx.tcz = cz; ctx.sum = csum; ctx.out = mine; ctx.y0 = 0; ctx.h = 256;
+ ctx.rx0 = 0; ctx.rx1 = 16; ctx.rz0 = 0; ctx.rz1 = 16; ctx.ry0 = 0; ctx.ry1 = 256;
+ cv = &ctx; caves_run();
+ int d = 0;
+ for (int y = 0; y < 256; y++) for (int z = 0; z < 16; z++) for (int x = 0; x < 16; x++) {
+ int a = ref[(y * 16 + z) * 16 + x], b = mine[y * 256 + z * 16 + x];
+ if (a == B_AIR && y < 60) carved++;
+ if (a != b) { if (d < 40) printf(" chunk %d,%d (%d,%d,%d): ref %d mine %d\n", cx, cz, x, y, z, a, b); d++; }
+ }
+ diff += d; tot += 65536; if (d) cdiff++;
+ }
+ printf("seed %lld: %ld / %ld blocks differ in %ld of %d chunks (air below 60 in ref: %ld)\n", (long long)seed, diff, tot, cdiff, n, carved);
+ return 0;
+}
diff --git a/games/numblocks/tests/gen/t_sintab.c b/games/numblocks/tests/gen/t_sintab.c
new file mode 100644
index 00000000..ed3638da
--- /dev/null
+++ b/games/numblocks/tests/gen/t_sintab.c
@@ -0,0 +1,33 @@
+/* Checks gen.c's MathHelper sin emulation against the exact table; with an argument, writes a new
+ * correction table (to paste into gen.c, replacing SIN_CORR and SIN_EXC). */
+#include "../../src/gen.c"
+#include <stdio.h>
+#include <math.h>
+static float ex(unsigned i) { return (float)sin((double)i * 3.141592653589793 * 2.0 / 65536.0); }
+int main(int argc, char **argv) {
+ int cnt[8] = {0}, big = 0; static unsigned exc[64][2];
+ unsigned char tab[4097]; memset(tab, 0, sizeof tab);
+ for (unsigned r = 0; r <= 16384; r++) {
+ float e = ex(r), p = sin_quadrant(r);
+ u32 be, bp; memcpy(&be, &e, 4); memcpy(&bp, &p, 4);
+ int d = (int)be - (int)bp;
+ if (d < -1 || d > 1) { exc[big][0] = r; exc[big][1] = be; big++; tab[r >> 2] |= (unsigned char)(3 << ((r & 3) * 2)); continue; }
+ cnt[d + 2]++;
+ tab[r >> 2] |= (unsigned char)(((d + 1) & 3) << ((r & 3) * 2));
+ }
+ printf("big %d, corrections -1:%d 0:%d +1:%d\n", big, cnt[1], cnt[2], cnt[3]);
+ if (argc > 1) {
+ FILE *f = fopen(argv[1], "w");
+ fprintf(f, "/* MathHelper sin table corrections (generated by tests/gen/t_sintab2.c): 2 bits per\n * first-quadrant index, value = correction in ulps + 1, 3 = see SIN_EXC */\nstatic const uint8_t SIN_CORR[4097] = {\n");
+ for (int i = 0; i < 4097; i++) fprintf(f, "%u,%s", tab[i], (i % 24 == 23) ? "\n" : "");
+ fprintf(f, "};\n/* entries whose correction is beyond one ulp: index, exact float bits */\nstatic const u32 SIN_EXC[][2] = {");
+ for (int i = 0; i < big; i++) fprintf(f, "{%u, 0x%08xu},", exc[i][0], exc[i][1]);
+ fprintf(f, "{65536, 0}};\n");
+ fclose(f);
+ }
+ /* verify full table */
+ int bad = 0;
+ for (unsigned i = 0; i < 65536; i++) if (sin_index(i) != ex(i)) bad++;
+ printf("full-table mismatches with current corrections: %d\n", bad);
+ return 0;
+}
diff --git a/games/numblocks/tests/play.c b/games/numblocks/tests/play.c
index 0ca8b332..8efcde2f 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;
+ int give = 0, title_screen = 0, mobs = 0, start_time = -1;
float hurt = 0;
int frames = 60, mspf = 50;
for (int i = 1; i < argc; i++) {
@@ -43,6 +43,8 @@ int main(int argc, char **argv) {
else if (!strcmp(argv[i], "--shots") && i + 1 < argc) shots = argv[++i];
else if (!strcmp(argv[i], "--give")) give = 1;
else if (!strcmp(argv[i], "--title")) title_screen = 1;
+ else if (!strcmp(argv[i], "--mobs")) mobs = 1;
+ 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) {
char *s = strdup(argv[++i]);
@@ -69,6 +71,22 @@ int main(int argc, char **argv) {
for (unsigned i = 0; i < sizeof kit / sizeof kit[0]; i++) inv_add(pl.inv, 36, kit[i][0], kit[i][1], 0);
pl.inv[0].aux = 100; /* a worn pickaxe */
}
+ if (start_time >= 0) {
+ extern uint32_t game_time;
+ game_time = (uint32_t)start_time;
+ }
+ if (mobs) {
+ /* a row of every mob, 4 blocks ahead, facing the player, on a cleared grass field */
+ int fy = (int)pl.y;
+ for (int z = (int)pl.z - 3; z < (int)pl.z + 9; z++)
+ for (int x = (int)pl.x - 9; x < (int)pl.x + 10; x++)
+ for (int y = fy - 1; y < fy + 8; y++) world_set(x, y, z, y == fy - 1 ? B_GRASS : B_AIR);
+ for (int k = 0; k < 8; k++) {
+ float x = pl.x - 5.6f + k * 1.6f, z = pl.z + 4.5f;
+ Entity *e = ent_new(E_ZOMBIE + k, x, (float)fy, z);
+ if (e) e->health = 20, e->yaw = 180, e->gx = e->x, e->gz = e->z;
+ }
+ }
if (hurt > 0) pl.health -= hurt, pl.food -= 7, pl.xp_level = 7, pl.xp = 0.4f;
double init_ms = (clock() - c0) * 1000.0 / CLOCKS_PER_SEC;
c0 = clock();
diff --git a/games/numblocks/tools/pack.py b/games/numblocks/tools/pack.py
index 01a60d73..a25db918 100644
--- a/games/numblocks/tools/pack.py
+++ b/games/numblocks/tools/pack.py
@@ -536,6 +536,31 @@ def main():
for g, members in items.GROUP_OF.items():
out.append(f'const uint16_t group_{g[2:].lower()}[] = {{' +
','.join(str(items.BNAMES.index(m)) for m in members) + ',0xFFFF};')
+ # mob skins: 64 x 32, 4 bits a texel, index 0 see-through
+ SKINS = ['zombie/zombie', 'skeleton/skeleton', 'creeper/creeper', 'spider/spider', 'pig/pig', 'cow/cow',
+ 'sheep/sheep', 'sheep/sheep_fur', 'chicken']
+ out.append(f'const uint8_t skin_px[{len(SKINS)}][1024] = {{')
+ spal = []
+ for n in SKINS:
+ im = jar.image('entity/' + n).crop((0, 0, 64, 32))
+ bs, pal, alpha = pack_sprite(im)
+ out.append(' {' + ','.join(str(v) for v in bs) + '},')
+ spal.append(pal)
+ out.append('};')
+ out.append(f'const uint16_t skin_pal[{len(SKINS)}][16] = {{')
+ for pal in spal:
+ out.append(' {' + ','.join(f'0x{rgb565(*c):04X}' for c in pal) + '},')
+ out.append('};')
+ # the cracks of a block being broken: 10 stages, 1 bit a texel (dark where set)
+ cr = []
+ for st in range(10):
+ im = jar.image(f'blocks/destroy_stage_{st}')
+ bits = [0] * 32
+ for i, (r, g, b, a) in enumerate(pixels(im)):
+ if a >= 100:
+ bits[i >> 3] |= 1 << (i & 7)
+ cr.append(bits)
+ out.append('const uint8_t cracks[10][32] = {' + ','.join('{' + ','.join(str(v) for v in b) + '}' for b in cr) + '};')
# the font
fb, fw = font_bits(jar)
out.append('const uint8_t font_bits[96 * 8] = {' + ','.join(str(v) for v in fb) + '};')
@@ -616,6 +641,10 @@ def main():
f'#define N_SMELTING {len(items.SMELT)}', 'extern const uint16_t smelting[N_SMELTING][2];']
for g in items.GROUP_OF:
h.append(f'extern const uint16_t group_{g[2:].lower()}[]; /* ends with 0xFFFF */')
+ h += ['extern const uint8_t skin_px[][1024]; /* mob skins, 64 x 32 */', 'extern const uint16_t skin_pal[][16];',
+ 'enum { SKIN_ZOMBIE, SKIN_SKELETON, SKIN_CREEPER, SKIN_SPIDER, SKIN_PIG, SKIN_COW, SKIN_SHEEP, SKIN_SHEEP_FUR,'
+ ' SKIN_CHICKEN };',
+ 'extern const uint8_t cracks[10][32]; /* destroy stages, 1 bit a texel */']
h += ['extern const uint8_t font_bits[96 * 8], font_w[96]; /* characters 32-127 */',
'extern const uint8_t img_rle[], img_w[], img_h[];', 'extern const uint32_t img_rows[];',
'extern const uint16_t img_row0[], img_pal[][16];']