{"id":309185,"date":"2020-08-29T21:00:16","date_gmt":"2020-08-29T21:00:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=309185"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-08-29T21:00:16","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=309185","title":{"rendered":"\u041a\u0430\u043a \u044f \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0432 IOCCC-&#8217;19 (\u0438 \u043f\u0440\u043e\u0438\u0433\u0440\u0430\u043b). \u0427\u0430\u0441\u0442\u044c 2: \u00ab\u0421\u0438\u043c\u0443\u043b\u044f\u0442\u043e\u0440 NOR\u00bb"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/516296\/\">\u042d\u0442\u043e \u0432\u0442\u043e\u0440\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0446\u0438\u043a\u043b\u0430 \u0441\u0442\u0430\u0442\u0435\u0439 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u044f \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0432 IOCCC&#8217;19<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/bi\/qj\/io\/biqjioey5bqopnw4dtnlmvc2skw.png\"><\/p>\n<ol>\n<li><a href=\"https:\/\/habr.com\/ru\/post\/505044\/\">\u041a\u0430\u043a \u044f \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0432 IOCCC-&#8217;19 (\u0438 \u043f\u0440\u043e\u0438\u0433\u0440\u0430\u043b). \u0427\u0430\u0441\u0442\u044c 1: \u00ab\u041a\u0440\u0435\u0441\u0442\u0438\u043a\u0438-\u043d\u043e\u043b\u0438\u043a\u0438\u00bb<\/a><\/li>\n<li><a href=\"#\">\u041a\u0430\u043a \u044f \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0432 IOCCC-&#8217;19 (\u0438 \u043f\u0440\u043e\u0438\u0433\u0440\u0430\u043b). \u0427\u0430\u0441\u0442\u044c 2: \u00ab\u0421\u0438\u043c\u0443\u043b\u044f\u0442\u043e\u0440 NOR\u00bb<\/a><\/li>\n<\/ol>\n<p>  \u042f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u043f\u0440\u0438 \u0440\u0430\u0437\u0431\u043e\u0440\u0435 \u0447\u0443\u0436\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438\u043b\u0438 \u043a\u043e\u0434\u0430 \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u0438\u043b\u0438 \u043e\u0431\u0444\u0443\u0441\u043a\u0430\u0442\u043e\u0440\u0430.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0435 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 IOCCC \u0438\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<p>  \u0412\u0441\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u044f \u0436\u0435\u043b\u0430\u044e \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f.<\/p>\n<p>  <a name=\"habracut\"><\/a><br \/>  \u0412\u0441\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u044b \u043d\u0430 <a href=\"https:\/\/github.com\/codemeow\/ioccc2020\/tree\/master\/nor\" rel=\"nofollow\">github<\/a>, \u043e\u0442\u043a\u0443\u0434\u0430 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u0432\u043e\u0437\u0431\u0440\u0430\u043d\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<h3>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h3>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c \u0432\u0438\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435, \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/wt\/yj\/48\/wtyj482dy-vsc16nhns_o8tv0hw.png\"><br \/>  \u0422\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e \u0441\u043b\u043e\u0436\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u00ab\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0430\u043b\u043b\u044b\u00bb \u0434\u0430\u044e\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u043a\u043e\u0434 \u043e\u0442\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u043d\u0435\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e \u0438\u043b\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435. \u0427\u0442\u043e \u0436, \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u044d\u0442\u043e \u0441 \u044d\u0442\u0438\u043c \u0437\u0434\u0435\u0441\u044c \u0432\u0441\u0451 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435.<\/p>\n<p>  \u041d\u043e \u0447\u0442\u043e \u0436\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430?<\/p>\n<p>  \u041e\u043d\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0442\u0435\u043a X-\u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u0440\u0438\u0441\u0443\u0435\u0442 \u044d\u043b\u0435\u043a\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0445\u0435\u043c\u0443 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0444\u0430\u0439\u043b\u0443 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u044e, \u043f\u043e\u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e \u043c\u0435\u043d\u044f\u044f \u043f\u043e\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c \u043d\u0430 4 \u043d\u043e\u0436\u043a\u0430\u0445 \u0432\u0445\u043e\u0434\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u043e\u043b\u044c\u043a\u043e NOR (Not-OR) \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b. \u041e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u043c \u0441\u0442\u0430\u0440\u043e\u0433\u043e LCD-\u044d\u043a\u0440\u0430\u043d\u0430.<\/p>\n<p>  \u0412 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u0435 \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439 \u0438\u0434\u0443\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e:  <\/p>\n<h4>DIP8-4packnot.txt \u2014 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u043e\u0433 CMOS 4041\/\u0427\u0435\u0442\u044b\u0440\u0435\u0445\u043a\u0430\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0432\u0435\u0440\u0442\u043e\u0440 <\/h4>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/sk\/zm\/0c\/skzm0chuicaqkmrmfpot1gzqi8m.gif\"><br \/>  (\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u0436\u0430\u0442\u043e \u0432 2 \u0440\u0430\u0437\u0430, \u0447\u0442\u043e\u0431\u044b \u0443\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u043c\u043a\u0438 \u043f\u0440\u0438\u043b\u0438\u0447\u0438\u044f. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0437\u0430\u0431\u0430\u0432\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u0432\u0435\u0441\u043e\u043c \u0432 3.5 \u041a\u0411 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0440\u044f\u0434 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0436\u0430\u0442\u0438\u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 10.5+\u041c\u0411)<\/p>\n<h4>DIP8-triplexor.txt \u2014 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u043e\u0433 CMOS 4030 \u0441 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u043c\u0438 \u0432\u0445\u043e\u0434\u0430\u043c\u0438 \u0438 \u0442\u0440\u0435\u043c\u044f \u043a\u0430\u043d\u0430\u043b\u0430\u043c\u0438\/\u0422\u0440\u0435\u0445\u043a\u0430\u043d\u0430\u043b\u044c\u043d\u044b\u0439 XOR-gate \u0441 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u043c\u0438 \u0432\u0445\u043e\u0434\u0430\u043c\u0438<\/h4>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ni\/ip\/gt\/niipgt33xnaubkq80bjw9wtgb5m.gif\"><\/p>\n<h4>DIP8-fulladder.txt \u2014 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u043e\u0433 CMOS 4008, \u043d\u043e \u043d\u0430 \u0434\u0432\u0430 \u0431\u0438\u0442\u0430\/\u0441\u0443\u043c\u043c\u0430\u0442\u043e\u0440 \u043d\u0430 2 \u0431\u0438\u0442\u0430 \u0441 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0431\u0438\u0442\u0430 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430<\/h4>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/p-\/ib\/s5\/p-ibs5w9vyv_nu0cqjmo30y67l0.gif\"><\/p>\n<h3>\u0420\u0430\u0437\u0431\u043e\u0440 \u043a\u043e\u0434\u0430<\/h3>\n<p>  \u0421\u0430\u043c\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0432 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0431\u044b\u043b\u043e \u0443\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0435\u043c\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b. \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430, \u043d\u043e \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u00ab\u0442\u043e\u043a\u0435\u043d\u043e\u0432\u00bb \u2014 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 \u044f\u0437\u044b\u043a\u0430 \u0438 \u043f\u0430\u0440 \u0441\u043a\u043e\u0431\u043e\u043a. \u0418\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u00ab\u0437\u0430\u044d\u043a\u0441\u043f\u043b\u043e\u0439\u0442\u0438\u0442\u044c\u00bb \u044d\u0442\u0443 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043f\u0430\u0440\u0441\u0435\u0440\u0430-\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u044c\u0449\u0438\u043a\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043e \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e define&#8217;\u043e\u0432, \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0449\u0438\u0445 \u0431\u043b\u043e\u043a\u0438 \u043a\u043e\u0434\u0430 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u043c\u0443 \u0441\u043b\u043e\u0432\u0443 \u044f\u0437\u044b\u043a\u0430 \u0421.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u0437\u0430\u0433\u043b\u044f\u043d\u0435\u043c \u0432 Makefile, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u043a\u043e\u0434 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f:<br \/>  <code>#!\/usr\/bin\/env make<br \/>  PROJECT=prog<br \/>  CC= gcc<br \/>  SRC=prog.c<br \/>  CWARN=-Wall -Wextra -Wno-char-subscripts<\/p>\n<p>  CSTD= -std=c99<br \/>  # Syscalls table<br \/>  # DS - syscall nanosleep<br \/>  # DO - syscall open<br \/>  # DR - syscall read<br \/>  # DC - syscall close<\/p>\n<p>  # X11 structures offsets<br \/>  # dS - offset of screens in Display<br \/>  # dR - offset of root in Screen<br \/>  # dD - offset of root_depth in Screen<br \/>  # dV - offset of root_visual in Screen<br \/>  # dG - offset of default_gc in Screen<\/p>\n<p>  BITS := $(shell uname -p)<\/p>\n<p>  ifeq ($(BITS), x86_64)<br \/>   ARCH= -m64<br \/>   CDEFINE= -DDS=35 -DDO=2 -DDR=0 -DDC=3 -DdS=232 -DdR=16 -DdD=56 -DdV=64 -DdG=72<br \/>  else<br \/>   ARCH= -m32<br \/>   CDEFINE= -DDS=162 -DDO=5 -DDR=3 -DDC=6 -DdS=140 -DdR=8 -DdD=36 -DdV=40 -DdG=44<br \/>  endif<\/p>\n<p>  OPT= -g<\/p>\n<p>  CFLAGS= ${CWARN} ${CSTD} ${ARCH} ${CDEFINE} ${OPT}<br \/>  LDFLAGS= -ldl<\/p>\n<p>  RM= rm<\/p>\n<p>  all: ${PROJECT}<\/p>\n<p>  ${PROJECT}:<br \/>   ${CC} ${CFLAGS} ${SRC} -o $@ ${LDFLAGS}<br \/>  clean:<br \/>   ${RM} -f ${PROJECT}<\/code><\/p>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u044d\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u0430, \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0430\u044f \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0443\u0440\u043e\u0434\u043b\u0438\u0432\u044b\u0445 &quot;#include&quot;, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0440\u0443\u0448\u0430\u044e\u0442 \u0443\u0437\u043e\u0440 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438. \u0417\u0430\u043f\u043e\u043c\u043d\u0438\u043c \u044d\u0442\u043e\u0442 \u0444\u0430\u043a\u0442 \u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u043b\u044f \u043f\u0440\u0435\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0438 \u043b\u0438\u043d\u0442\u0435\u0440\u0430:  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u0435\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">gcc -DDS=35 -DDO=2 -DDR=0 -DDC=3 -DdS=232 -DdR=16 -DdD=56 -DdV=64 -DdG=72 prog.c -ldl -E | indent -kr -brf &gt; \/tmp\/fmt.c<\/code><\/pre>\n<p>:  <\/p>\n<pre><code class=\"cpp\">int _x[] = { 15117427, 8413248, 5878632, 13027014, 1 };  extern void *dlsym(void *, char *); int x_[616][1220]; extern long syscall(long, ...); extern void *dlopen(char *, int); char m[19][20], _n[] =     &quot;pu~D--2os&quot; &quot;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&quot; &quot;&lt;&lt;&lt;DSlyrXuolp}e&quot; &quot;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&quot;     &quot;D_ny}hyOuqlpyKurxsk&lt;D_ny&quot; &quot;}hyUq}{y&quot; &quot;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&quot; &quot;DLihUq}{y&quot; &quot;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&quot;     &quot;&lt;&lt;&lt;DQ}lKurxsk&quot; &quot;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&quot; &quot;&lt;&lt;DZpiot&lt;&quot;; long w, N[2] = { 0, 1 &lt;&lt; 29 }; int rn = 2166136261, _[8][40][64] = { 0 }; long R[2]; void *M, *d, *T;  void b(int t, int x, int y, int c, int l) {     if ((x &gt;= 19 || y &gt;= 19 || x &lt; 0 || y &lt; 0) || (m[y][x] == l) \t|| (m[y][x] != c)) \treturn;     m[y][x] = l;     b(t, x - 1, y, c, l);     b(t, x + 1, y, c, l);     b(t, x, y - 1, c, l);     b(t, x, y + 1, c, l); }  void e(int t, int x, int y, int c, int l) {     if ((x &gt;= 64 || y &gt;= 40 || x &lt; 0 || y &lt; 0) || (_[t][y][x] == l) \t|| (_[t][y][x] != c)) \treturn;     _[t][y][x] = l;     e(t, x - 1, y, c, l);     e(t, x + 1, y, c, l);     e(t, x, y - 1, c, l);     e(t, x, y + 1, c, l); }  void k(int t, int x, int y, int c, int l) {     while (c--) { \t_[t][y][x++] = l; \t_[t][y++][x++] = l;     } }  void r(int t, int x, int y, int c, int l) {     while (c--) { \t_[t][y][x--] = l; \t_[t][y++][x--] = l;     } }  void u(int t, int x, int y, int c, int l) {     while (c--) \t_[t][y++][x] = l; }  char *z[8] = {      (char[]) {4},      (char[]) {6, 1 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16, 0, 0, \t\t     21 + 0 * 3 - 0, 16, 1, 63, 21 + 0 * 3 - 0, 16, 2, \t\t     63 * 0, 21 - 0, 4, 2, 31 + 0, 36 - 0, 4, 0 + 1, \t\t     32 - 1, 5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1, 63, \t\t     21 + 1 * 3 - 0, 16, 2, 63 * 1, 21 - 0, 4, 2, 31 + 1, \t\t     36 - 0, 4, 6, 1 * 4 + 0, 3, 31, 8 - 0, 6, 1 * 4 + 2, \t\t     3, 33, 38 - 0, 6, 1 * 4 + 3, 3, 30, 38 - 0, 4}, \t(char[]) {5, 1},  \t(char[]) {6, 0 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16, \t\t\t\t   0, 0, 21 + 0 * 3 - 0, 16, 1, 63, \t\t\t\t   21 + 0 * 3 - 0, 16, 2, 63 * 0, 21 - 0, \t\t\t\t   4, 2, 31 + 0, 36 - 0, 4, 0 + 1, 32 - 1, \t\t\t\t   5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1, \t\t\t\t   63, 21 + 1 * 3 - 0, 16, 2, 63 * 1, \t\t\t\t   21 - 0, 4, 2, 31 + 1, 36 - 0, 4, 6, \t\t\t\t   0 * 4 + 0, 3, 31, 8 - 0, 6, 0 * 4 + 2, \t\t\t\t   3, 33, 38 - 0, 6, 0 * 4 + 3, 3, 30, \t\t\t\t   38 - 0, \t\t\t\t   4}, \t(char[]) {4}, (char[]) {4}, \t(char[]) {6, 2 * 4 + 1, 0 + 0, 32 - 0, 5 - 3, 16, 0, 0, \t\t  21 + 0 * 3 - 3, 16, 1, 63, 21 + 0 * 3 - 3, 16, 2, 63 * 0, \t\t  21 - 3, 4, 2, 31 + 0, 36 - 3, 4, 0 + 1, 32 - 1, 5 - 3, \t\t  16, 0, 0, 21 + 1 * 3 - 3, 16, 1, 63, 21 + 1 * 3 - 3, 16, \t\t  2, 63 * 1, 21 - 3, 4, 2, 31 + 1, 36 - 3, 4, 6, 2 * 4 + 0, \t\t  3, 31, 8 - 3, 6, 2 * 4 + 2, 3, 33, 38 - 3, 6, 2 * 4 + 3, \t\t  3, 30, 38 - 3, 4},      (char[]) {6, 13, 0, 32, 9 + 0, 12 - 0, \t\t\t\t\t       0, 8 + 0 + 0, 21, 12 - 0, 1, \t\t\t\t\t       31, 9 + 0, 12 - 0, 1, \t\t\t\t\t       55 - 0 - 0, 21, 12 - 0, 0, \t\t\t\t\t       32, 9 + 3, 12 - 3, 0, \t\t\t\t\t       8 + 3 + 3, 21, 12 - 3, 1, \t\t\t\t\t       31, 9 + 3, 12 - 3, 1, \t\t\t\t\t       55 - 3 - 3, 21, 12 - 3, 6, \t\t\t\t\t       14 + 0, 2, 31 + 0, 13, 4, \t\t\t\t\t       1 - 0, 31 + 0, 16, 7, 3, \t\t\t\t\t       30 + 3 * 0, 14, 6, \t\t\t\t\t       12 + 0 * 4, 3, 32 - 0, \t\t\t\t\t       11 + 0 * 8, 6, 14 + 1, 2, \t\t\t\t\t       31 + 1, 13, 4, 1 - 1, \t\t\t\t\t       31 + 1, 16, 7, 3, \t\t\t\t\t       30 + 3 * 1, 14, 6, \t\t\t\t\t       12 + 1 * 4, 3, 32 - 1, \t\t\t\t\t       11 + 1 * 8, \t\t\t\t\t       4} };  void d_(int t, int p, int q) {     for (int y = 0; y &lt; 40; y++) \tfor (int x = 0; x &lt; 64; x++) \t    if (_[t] \t\t[y][x]) \t\tx_[y + q * 16 + p * 16][x + 580 + p * 32 - q * \t\t\t\t\t32] = _[t][y][x]; }  int main(int a, char *s[]) {     int h = 127;     while (h--) { \t_n[h] ^= 28; \t_n[h] -= (_n[h] == 32 ? 32 : 0);     }     T = dlopen(_n, 2);     d = ((void *(*)()) dlsym(T, _n + (1 * 20))) (0);     w = ((long (*)()) dlsym(T, _n + (2 * 20))) (d, \t\t\t\t\t\t(*(long *) \t\t\t\t\t\t ((char \t\t\t\t\t\t   *) (*(long *) ((char *) \t\t\t\t\t\t\t\t  d + \t\t\t\t\t\t\t\t  232)) + \t\t\t\t\t\t  16))    \t\t\t\t\t\t, 0, 0, 1220, 616, 1, 0, \t\t\t\t\t\t0);     M = ((void *(*)()) dlsym(T, _n + (3 * 20))) (d, \t\t\t\t\t\t (*(long *) \t\t\t\t\t\t  ((char \t\t\t\t\t\t    *) (*(long *) ((char *) \t\t\t\t\t\t\t\t   d + \t\t\t\t\t\t\t\t   232)) + \t\t\t\t\t\t   64)), \t\t\t\t\t\t (*(long *) \t\t\t\t\t\t  ((char \t\t\t\t\t\t    *) (*(long *) ((char *) \t\t\t\t\t\t\t\t   d + \t\t\t\t\t\t\t\t   232)) + \t\t\t\t\t\t   56)), 2, 0, (char *) x_, \t\t\t\t\t\t 1220, 616, 32, 0);     for (int i = 0; i &lt; 8; i++) { \tchar *p = z[i]; \tint c = 0; \twhile (*p != 4) { \t    switch (*p) { \t    case 0: \t\tk(i, p[1], p[2], p[3], c); \t\tp += 4; \t\tbreak; \t    case 1: \t\tr(i, p[1], p[2], p[3], c); \t\tp += 4; \t\tbreak; \t    case 2: \t\tu(i, p[1], p[2], p[3], c); \t\tp += 4; \t\tbreak; \t    case 3: \t\te(i, p[1] \t\t  , p[2], 0, c); \t\tp += 3; \t\tbreak; \t    case 5: \t\tp = z[p[1]]; \t\tbreak; \t    case 6: \t\tc = _x[p[1] \/ 4] - 1643277 * (p[1] % 4); \t\tp += 2; \t\tbreak; \t    } \t}     }     while (a++) { \tint f = syscall(2, s[1], 0); \tsyscall(0, f, m, 380); \tsyscall(3, f); \tfor (int y = 0; y &lt; 19; y++) \t    for (int x = 0; x &lt; 19; x++) \t\tif ((x % 14 == 2) &amp;&amp; (y % 4 == 3)) \t\t    m[y][x] = 46; \tb(0, 2, 3, m[3][2], a &amp; 1 ? 43 : 45); \tb(0, 2, 7, m[7][2], a &amp; 2 ? 43 : 45); \tb(0, 2, 11, m[11][2], a &amp; 4 ? 43 : 45); \tb(0, 2, 15, m[15][2], a &amp; 8 ? 43 : 45); \tfor (int i = 0; i &lt; 20; i++) \t    for (int y = 0; y &lt; 19; y++) \t\tfor (int x = 0; x &lt; 19; x++) \t\t    if (m[y][x] == 62) \t\t\tb(0, x + 1, y, m[y][x + 1], \t\t\t  !(m[y - 1][x] == 43 ? 1 : 0 \t\t\t    || m[y + 1][x] == 43 ? 1 : 0) ? 43 : 45); \tfor (int y = 0; y &lt; 616; y++) \t    for (int x = 0; x &lt; 1220; x++) \t\tx_[y][x] = 0; \tfor (int y = 0; y &lt; 19; y++) \t    for (int x = 0; x &lt; 19; x++) \t\td_(((m[y][x] &gt;&gt; 4) &amp; 1) &lt;&lt; 2 | (m[y][x] &amp; 3), x, y); \tfor (int y = 0; y &lt; 19; y++) \t    for (int x = 0; x &lt; 19; x++) \t\tif ((x % 14 == 2) &amp;&amp; (y % 4 == 3)) \t\t    d_(7, x, y); \tfor (int y = 0; y &lt; 616; y++) \t    for (int x = 0; x &lt; 1220; x++) { \t\tx_[y][x] &amp;= 14737632 | (31 &lt;&lt; ((x % 3) &lt;&lt; 3)); \t\tx_[y][x] += 986895 &amp; (rn *= 16777619); \t    } ((long (*)()) dlsym(T, _n + (4 * 20))) (d, w, \t\t\t\t\t\t      (*(long *) \t\t\t\t\t\t       ((char \t\t\t\t\t\t\t *) (*(long \t\t\t\t\t\t\t       *) ((char *) \t\t\t\t\t\t\t\t   d + \t\t\t\t\t\t\t\t   232)) + \t\t\t\t\t\t\t72)), M, 0, 0, 0, \t\t\t\t\t\t      0, 1220, 616); \t((long (*)()) dlsym(T, _n + (5 * 20))) (d, w); \t((long (*)()) dlsym(T, _n + (6 * 20))) (d); \tsyscall(35, &amp;N, &amp;R);     } return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0427\u0442\u043e \u0436, \u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u043e\u0434\u043d\u043e \u0438\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0430 \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0438, \u043a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0435\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435 \u043d\u0435 \u0441\u0442\u0430\u043b.<\/p>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043b\u043e\u0432\u0438\u0442\u044c \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0432\u0437\u0433\u043b\u044f\u0434\u0430 \u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0441\u043e\u0431\u044b\u0442\u0438\u0439:  <\/p>\n<h4>dlsym\\dlopen<\/h4>\n<p>  \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0447\u0442\u043e\u0431\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 X-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u043a\u043d\u043e, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432 \u043d\u0435\u043c \u0447\u0442\u043e-\u0442\u043e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 XLib. \u0412 \u043a\u043e\u0434\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 dlopen\/dlsym, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043e\u0434\u043d\u0430\u043a\u043e \u043d\u0430 \u0432\u0445\u043e\u0434 \u0438\u043c \u043f\u043e\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0445\u0438\u0442\u0440\u0430\u044f \u043a\u0430\u0448\u0430:  <\/p>\n<pre><code class=\"cpp\"> char _n[] =     &quot;pu~D--2os&quot; &quot;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&quot; &quot;&lt;&lt;&lt;DSlyrXuolp}e&quot; &quot;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&quot;     &quot;D_ny}hyOuqlpyKurxsk&lt;D_ny&quot; &quot;}hyUq}{y&quot; &quot;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&quot; &quot;DLihUq}{y&quot; &quot;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&quot;     &quot;&lt;&lt;&lt;DQ}lKurxsk&quot; &quot;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&quot; &quot;&lt;&lt;DZpiot&lt;&quot;; ... T = dlopen(_n, 2);<\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0439\u0434\u0435\u043c \u043d\u0430 \u0448\u0430\u0433 \u043d\u0430\u0437\u0430\u0434 \u0438 \u043f\u0440\u043e\u0438\u043d\u0441\u043f\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:  <\/p>\n<pre><code class=\"cpp\">int h = 127;     while (h--) { \t_n[h] ^= 28; \t_n[h] -= (_n[h] == 32 ? 32 : 0);     }<\/code><\/pre>\n<p>  \u0421\u0443\u0434\u044f \u043f\u043e \u0432\u0441\u0435\u043c\u0443, \u043e\u043d \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u043d\u0430\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0435\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e:<br \/>  <a href=\"https:\/\/onlinegdb.com\/SJNM9Og7v\" rel=\"nofollow\">https:\/\/onlinegdb.com\/SJNM9Og7v<\/a>:<br \/>  <code>libX11.so <br \/>  XOpenDisplay <br \/>  XCreateSimpleWindow <br \/>  XCreateImage <br \/>  XPutImage <br \/>  XMapWindow <br \/>  XFlush <\/code><br \/>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u043b\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e\u0434 \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0438\u0440\u0443\u0435\u0442 \u0442\u043e\u0442 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435 \u044f\u0437\u044b\u043a\u0430 \u0421 (void) \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0430 () \u2014 \u043b\u044e\u0431\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 void * \u043a \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 ((long (*)()) \u0442\u0438\u043f\u0443 \u0438 \u0432\u0443\u0430\u043b\u044f:  <\/p>\n<pre><code class=\"cpp\">w = ((long (*)()) dlsym(T, _n + (2 * 20))) (d, (*(long *)((char *) (*(long *)((char *) d + 232)) + 16))<\/code><\/pre>\n<p>  \u0417\u043d\u0430\u044f, \u0447\u0442\u043e \u044d\u0442\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0442\u043e\u043b\u044c \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 dlsym \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0438:  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043c\u0435\u043d\u044b \u0441\u0442\u0440\u043e\u043a:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">int _x[] = { 15117427, 8413248, 5878632, 13027014, 1 };  extern void *dlsym(void *, char *); int x_[616][1220]; extern long syscall(long, ...); extern void *dlopen(char *, int); char m[19][20]; long w, N[2] = { 0, 1 &lt;&lt; 29 }; int rn = 2166136261, _[8][40][64] = { 0 }; long R[2]; void *M, *d, *T;  void b(int t, int x, int y, int c, int l) {     if ((x &gt;= 19 || y &gt;= 19 || x &lt; 0 || y &lt; 0) || (m[y][x] == l) \t|| (m[y][x] != c)) \treturn;     m[y][x] = l;     b(t, x - 1, y, c, l);     b(t, x + 1, y, c, l);     b(t, x, y - 1, c, l);     b(t, x, y + 1, c, l); }  void e(int t, int x, int y, int c, int l) {     if ((x &gt;= 64 || y &gt;= 40 || x &lt; 0 || y &lt; 0) || (_[t][y][x] == l) \t|| (_[t][y][x] != c)) \treturn;     _[t][y][x] = l;     e(t, x - 1, y, c, l);     e(t, x + 1, y, c, l);     e(t, x, y - 1, c, l);     e(t, x, y + 1, c, l); }  void k(int t, int x, int y, int c, int l) {     while (c--) { \t_[t][y][x++] = l; \t_[t][y++][x++] = l;     } }  void r(int t, int x, int y, int c, int l) {     while (c--) { \t_[t][y][x--] = l; \t_[t][y++][x--] = l;     } }  void u(int t, int x, int y, int c, int l) {     while (c--) \t_[t][y++][x] = l; }  char *z[8] = {      (char[]) {4},      (char[]) {6, 1 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16, 0, 0, \t\t     21 + 0 * 3 - 0, 16, 1, 63, 21 + 0 * 3 - 0, 16, 2, \t\t     63 * 0, 21 - 0, 4, 2, 31 + 0, 36 - 0, 4, 0 + 1, \t\t     32 - 1, 5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1, 63, \t\t     21 + 1 * 3 - 0, 16, 2, 63 * 1, 21 - 0, 4, 2, 31 + 1, \t\t     36 - 0, 4, 6, 1 * 4 + 0, 3, 31, 8 - 0, 6, 1 * 4 + 2, \t\t     3, 33, 38 - 0, 6, 1 * 4 + 3, 3, 30, 38 - 0, 4}, \t(char[]) {5, 1},  \t(char[]) {6, 0 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16, \t\t\t\t   0, 0, 21 + 0 * 3 - 0, 16, 1, 63, \t\t\t\t   21 + 0 * 3 - 0, 16, 2, 63 * 0, 21 - 0, \t\t\t\t   4, 2, 31 + 0, 36 - 0, 4, 0 + 1, 32 - 1, \t\t\t\t   5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1, \t\t\t\t   63, 21 + 1 * 3 - 0, 16, 2, 63 * 1, \t\t\t\t   21 - 0, 4, 2, 31 + 1, 36 - 0, 4, 6, \t\t\t\t   0 * 4 + 0, 3, 31, 8 - 0, 6, 0 * 4 + 2, \t\t\t\t   3, 33, 38 - 0, 6, 0 * 4 + 3, 3, 30, \t\t\t\t   38 - 0, \t\t\t\t   4}, \t(char[]) {4}, (char[]) {4}, \t(char[]) {6, 2 * 4 + 1, 0 + 0, 32 - 0, 5 - 3, 16, 0, 0, \t\t  21 + 0 * 3 - 3, 16, 1, 63, 21 + 0 * 3 - 3, 16, 2, 63 * 0, \t\t  21 - 3, 4, 2, 31 + 0, 36 - 3, 4, 0 + 1, 32 - 1, 5 - 3, \t\t  16, 0, 0, 21 + 1 * 3 - 3, 16, 1, 63, 21 + 1 * 3 - 3, 16, \t\t  2, 63 * 1, 21 - 3, 4, 2, 31 + 1, 36 - 3, 4, 6, 2 * 4 + 0, \t\t  3, 31, 8 - 3, 6, 2 * 4 + 2, 3, 33, 38 - 3, 6, 2 * 4 + 3, \t\t  3, 30, 38 - 3, 4},      (char[]) {6, 13, 0, 32, 9 + 0, 12 - 0, \t\t\t\t\t       0, 8 + 0 + 0, 21, 12 - 0, 1, \t\t\t\t\t       31, 9 + 0, 12 - 0, 1, \t\t\t\t\t       55 - 0 - 0, 21, 12 - 0, 0, \t\t\t\t\t       32, 9 + 3, 12 - 3, 0, \t\t\t\t\t       8 + 3 + 3, 21, 12 - 3, 1, \t\t\t\t\t       31, 9 + 3, 12 - 3, 1, \t\t\t\t\t       55 - 3 - 3, 21, 12 - 3, 6, \t\t\t\t\t       14 + 0, 2, 31 + 0, 13, 4, \t\t\t\t\t       1 - 0, 31 + 0, 16, 7, 3, \t\t\t\t\t       30 + 3 * 0, 14, 6, \t\t\t\t\t       12 + 0 * 4, 3, 32 - 0, \t\t\t\t\t       11 + 0 * 8, 6, 14 + 1, 2, \t\t\t\t\t       31 + 1, 13, 4, 1 - 1, \t\t\t\t\t       31 + 1, 16, 7, 3, \t\t\t\t\t       30 + 3 * 1, 14, 6, \t\t\t\t\t       12 + 1 * 4, 3, 32 - 1, \t\t\t\t\t       11 + 1 * 8, \t\t\t\t\t       4} };  void d_(int t, int p, int q) {     for (int y = 0; y &lt; 40; y++) \tfor (int x = 0; x &lt; 64; x++) \t    if (_[t] \t\t[y][x]) \t\tx_[y + q * 16 + p * 16][x + 580 + p * 32 - q * \t\t\t\t\t32] = _[t][y][x]; }  int main(int a, char *s[]) {     T = dlopen(&quot;libX11.so&quot;, 2);     d = ((void *(*)()) dlsym(T, &quot;XOpenDisplay&quot;) (0);     w = ((long (*)()) dlsym(T, &quot;XCreateSimpleWindow&quot;)) (d, \t\t\t\t\t\t(*(long *) \t\t\t\t\t\t ((char \t\t\t\t\t\t   *) (*(long *) ((char *) \t\t\t\t\t\t\t\t  d + \t\t\t\t\t\t\t\t  232)) + \t\t\t\t\t\t  16))    \t\t\t\t\t\t, 0, 0, 1220, 616, 1, 0, \t\t\t\t\t\t0);     M = ((void *(*)()) dlsym(T, &quot;XCreateImage&quot;)) (d, \t\t\t\t\t\t (*(long *) \t\t\t\t\t\t  ((char \t\t\t\t\t\t    *) (*(long *) ((char *) \t\t\t\t\t\t\t\t   d + \t\t\t\t\t\t\t\t   232)) + \t\t\t\t\t\t   64)), \t\t\t\t\t\t (*(long *) \t\t\t\t\t\t  ((char \t\t\t\t\t\t    *) (*(long *) ((char *) \t\t\t\t\t\t\t\t   d + \t\t\t\t\t\t\t\t   232)) + \t\t\t\t\t\t   56)), 2, 0, (char *) x_, \t\t\t\t\t\t 1220, 616, 32, 0);     for (int i = 0; i &lt; 8; i++) { \tchar *p = z[i]; \tint c = 0; \twhile (*p != 4) { \t    switch (*p) { \t    case 0: \t\tk(i, p[1], p[2], p[3], c); \t\tp += 4; \t\tbreak; \t    case 1: \t\tr(i, p[1], p[2], p[3], c); \t\tp += 4; \t\tbreak; \t    case 2: \t\tu(i, p[1], p[2], p[3], c); \t\tp += 4; \t\tbreak; \t    case 3: \t\te(i, p[1] \t\t  , p[2], 0, c); \t\tp += 3; \t\tbreak; \t    case 5: \t\tp = z[p[1]]; \t\tbreak; \t    case 6: \t\tc = _x[p[1] \/ 4] - 1643277 * (p[1] % 4); \t\tp += 2; \t\tbreak; \t    } \t}     }     while (a++) { \tint f = syscall(2, s[1], 0); \tsyscall(0, f, m, 380); \tsyscall(3, f); \tfor (int y = 0; y &lt; 19; y++) \t    for (int x = 0; x &lt; 19; x++) \t\tif ((x % 14 == 2) &amp;&amp; (y % 4 == 3)) \t\t    m[y][x] = 46; \tb(0, 2, 3, m[3][2], a &amp; 1 ? 43 : 45); \tb(0, 2, 7, m[7][2], a &amp; 2 ? 43 : 45); \tb(0, 2, 11, m[11][2], a &amp; 4 ? 43 : 45); \tb(0, 2, 15, m[15][2], a &amp; 8 ? 43 : 45); \tfor (int i = 0; i &lt; 20; i++) \t    for (int y = 0; y &lt; 19; y++) \t\tfor (int x = 0; x &lt; 19; x++) \t\t    if (m[y][x] == 62) \t\t\tb(0, x + 1, y, m[y][x + 1], \t\t\t  !(m[y - 1][x] == 43 ? 1 : 0 \t\t\t    || m[y + 1][x] == 43 ? 1 : 0) ? 43 : 45); \tfor (int y = 0; y &lt; 616; y++) \t    for (int x = 0; x &lt; 1220; x++) \t\tx_[y][x] = 0; \tfor (int y = 0; y &lt; 19; y++) \t    for (int x = 0; x &lt; 19; x++) \t\td_(((m[y][x] &gt;&gt; 4) &amp; 1) &lt;&lt; 2 | (m[y][x] &amp; 3), x, y); \tfor (int y = 0; y &lt; 19; y++) \t    for (int x = 0; x &lt; 19; x++) \t\tif ((x % 14 == 2) &amp;&amp; (y % 4 == 3)) \t\t    d_(7, x, y); \tfor (int y = 0; y &lt; 616; y++) \t    for (int x = 0; x &lt; 1220; x++) { \t\tx_[y][x] &amp;= 14737632 | (31 &lt;&lt; ((x % 3) &lt;&lt; 3)); \t\tx_[y][x] += 986895 &amp; (rn *= 16777619); \t    } ((long (*)()) dlsym(T, &quot;XPutImage&quot;)) (d, w, \t\t\t\t\t\t      (*(long *) \t\t\t\t\t\t       ((char \t\t\t\t\t\t\t *) (*(long \t\t\t\t\t\t\t       *) ((char *) \t\t\t\t\t\t\t\t   d + \t\t\t\t\t\t\t\t   232)) + \t\t\t\t\t\t\t72)), M, 0, 0, 0, \t\t\t\t\t\t      0, 1220, 616); \t((long (*)()) dlsym(T, &quot;XMapWindow&quot;)) (d, w); \t((long (*)()) dlsym(T, &quot;XFlush&quot;)) (d); \tsyscall(35, &amp;N, &amp;R);     } return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0410 \u043f\u043e\u0442\u043e\u043c \u0438 \u043d\u0430 \u0440\u043e\u0434\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043c\u0435\u043d\u044b \u043d\u0430 &#39;&#39;\u0440\u043e\u0434\u043d\u044b\u0435&#39;&#39; \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;X11\/Xlib.h&gt;  int _x[] = { 15117427, 8413248, 5878632, 13027014, 1 };  int x_[616][1220]; extern long syscall(long, ...); char m[19][20]; long w, N[2] = { 0, 1 &lt;&lt; 29 }; int rn = 2166136261, _[8][40][64] = { 0 }; long R[2]; void *M, *d, *T;  void b(int t, int x, int y, int c, int l) {     if ((x &gt;= 19 || y &gt;= 19 || x &lt; 0 || y &lt; 0) || (m[y][x] == l) \t|| (m[y][x] != c)) \treturn;     m[y][x] = l;     b(t, x - 1, y, c, l);     b(t, x + 1, y, c, l);     b(t, x, y - 1, c, l);     b(t, x, y + 1, c, l); }  void e(int t, int x, int y, int c, int l) {     if ((x &gt;= 64 || y &gt;= 40 || x &lt; 0 || y &lt; 0) || (_[t][y][x] == l) \t|| (_[t][y][x] != c)) \treturn;     _[t][y][x] = l;     e(t, x - 1, y, c, l);     e(t, x + 1, y, c, l);     e(t, x, y - 1, c, l);     e(t, x, y + 1, c, l); }  void k(int t, int x, int y, int c, int l) {     while (c--) { \t_[t][y][x++] = l; \t_[t][y++][x++] = l;     } }  void r(int t, int x, int y, int c, int l) {     while (c--) { \t_[t][y][x--] = l; \t_[t][y++][x--] = l;     } }  void u(int t, int x, int y, int c, int l) {     while (c--) \t_[t][y++][x] = l; }  char *z[8] = {      (char[]) {4},      (char[]) {6, 1 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16, 0, 0, \t\t     21 + 0 * 3 - 0, 16, 1, 63, 21 + 0 * 3 - 0, 16, 2, \t\t     63 * 0, 21 - 0, 4, 2, 31 + 0, 36 - 0, 4, 0 + 1, \t\t     32 - 1, 5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1, 63, \t\t     21 + 1 * 3 - 0, 16, 2, 63 * 1, 21 - 0, 4, 2, 31 + 1, \t\t     36 - 0, 4, 6, 1 * 4 + 0, 3, 31, 8 - 0, 6, 1 * 4 + 2, \t\t     3, 33, 38 - 0, 6, 1 * 4 + 3, 3, 30, 38 - 0, 4}, \t(char[]) {5, 1},  \t(char[]) {6, 0 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16, \t\t\t\t   0, 0, 21 + 0 * 3 - 0, 16, 1, 63, \t\t\t\t   21 + 0 * 3 - 0, 16, 2, 63 * 0, 21 - 0, \t\t\t\t   4, 2, 31 + 0, 36 - 0, 4, 0 + 1, 32 - 1, \t\t\t\t   5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1, \t\t\t\t   63, 21 + 1 * 3 - 0, 16, 2, 63 * 1, \t\t\t\t   21 - 0, 4, 2, 31 + 1, 36 - 0, 4, 6, \t\t\t\t   0 * 4 + 0, 3, 31, 8 - 0, 6, 0 * 4 + 2, \t\t\t\t   3, 33, 38 - 0, 6, 0 * 4 + 3, 3, 30, \t\t\t\t   38 - 0, \t\t\t\t   4}, \t(char[]) {4}, (char[]) {4}, \t(char[]) {6, 2 * 4 + 1, 0 + 0, 32 - 0, 5 - 3, 16, 0, 0, \t\t  21 + 0 * 3 - 3, 16, 1, 63, 21 + 0 * 3 - 3, 16, 2, 63 * 0, \t\t  21 - 3, 4, 2, 31 + 0, 36 - 3, 4, 0 + 1, 32 - 1, 5 - 3, \t\t  16, 0, 0, 21 + 1 * 3 - 3, 16, 1, 63, 21 + 1 * 3 - 3, 16, \t\t  2, 63 * 1, 21 - 3, 4, 2, 31 + 1, 36 - 3, 4, 6, 2 * 4 + 0, \t\t  3, 31, 8 - 3, 6, 2 * 4 + 2, 3, 33, 38 - 3, 6, 2 * 4 + 3, \t\t  3, 30, 38 - 3, 4},      (char[]) {6, 13, 0, 32, 9 + 0, 12 - 0, \t\t\t\t\t       0, 8 + 0 + 0, 21, 12 - 0, 1, \t\t\t\t\t       31, 9 + 0, 12 - 0, 1, \t\t\t\t\t       55 - 0 - 0, 21, 12 - 0, 0, \t\t\t\t\t       32, 9 + 3, 12 - 3, 0, \t\t\t\t\t       8 + 3 + 3, 21, 12 - 3, 1, \t\t\t\t\t       31, 9 + 3, 12 - 3, 1, \t\t\t\t\t       55 - 3 - 3, 21, 12 - 3, 6, \t\t\t\t\t       14 + 0, 2, 31 + 0, 13, 4, \t\t\t\t\t       1 - 0, 31 + 0, 16, 7, 3, \t\t\t\t\t       30 + 3 * 0, 14, 6, \t\t\t\t\t       12 + 0 * 4, 3, 32 - 0, \t\t\t\t\t       11 + 0 * 8, 6, 14 + 1, 2, \t\t\t\t\t       31 + 1, 13, 4, 1 - 1, \t\t\t\t\t       31 + 1, 16, 7, 3, \t\t\t\t\t       30 + 3 * 1, 14, 6, \t\t\t\t\t       12 + 1 * 4, 3, 32 - 1, \t\t\t\t\t       11 + 1 * 8, \t\t\t\t\t       4} };  void d_(int t, int p, int q) {     for (int y = 0; y &lt; 40; y++) \tfor (int x = 0; x &lt; 64; x++) \t    if (_[t] \t\t[y][x]) \t\tx_[y + q * 16 + p * 16][x + 580 + p * 32 - q * \t\t\t\t\t32] = _[t][y][x]; }  int main(int a, char *s[]) {     d = XOpenDisplay(0);     w = XCreateSimpleWindow(d, (*(long *) ((char *) (*(long *) ((char *)d + 232)) + 16)), 0, 0, 1220, 616, 1, 0, 0);     M = XCreateImage(d, (*(long *)((char *) (*(long *) ((char *)d + 232)) + 64)), (*(long *)((char *) (*(long *) ((char *)d + 232)) + 56)), 2, 0, (char *) x_, 1220, 616, 32, 0);     for (int i = 0; i &lt; 8; i++) { \t    char *p = z[i]; \t    int c = 0; \t    while (*p != 4) { \t        switch (*p) { \t        case 0: \t    \t    k(i, p[1], p[2], p[3], c); \t    \t    p += 4; \t    \t    break; \t        case 1: \t    \t    r(i, p[1], p[2], p[3], c); \t    \t    p += 4; \t    \t    break; \t        case 2: \t    \t    u(i, p[1], p[2], p[3], c); \t    \t    p += 4; \t    \t    break; \t        case 3: \t    \t    e(i, p[1] \t    \t      , p[2], 0, c); \t    \t    p += 3; \t    \t    break; \t        case 5: \t    \t    p = z[p[1]]; \t    \t    break; \t        case 6: \t    \t    c = _x[p[1] \/ 4] - 1643277 * (p[1] % 4); \t    \t    p += 2; \t    \t    break; \t        } \t    }     }     while (a++) { \t    int f = syscall(2, s[1], 0); \t    syscall(0, f, m, 380); \t    syscall(3, f); \t    for (int y = 0; y &lt; 19; y++) \t        for (int x = 0; x &lt; 19; x++) \t\t    if ((x % 14 == 2) &amp;&amp; (y % 4 == 3)) \t\t        m[y][x] = 46; \t    b(0, 2, 3, m[3][2], a &amp; 1 ? 43 : 45); \t    b(0, 2, 7, m[7][2], a &amp; 2 ? 43 : 45); \t    b(0, 2, 11, m[11][2], a &amp; 4 ? 43 : 45); \t    b(0, 2, 15, m[15][2], a &amp; 8 ? 43 : 45); \t    for (int i = 0; i &lt; 20; i++) \t        for (int y = 0; y &lt; 19; y++) \t\t    for (int x = 0; x &lt; 19; x++) \t\t        if (m[y][x] == 62) \t\t\t    b(0, x + 1, y, m[y][x + 1], \t\t\t    !(m[y - 1][x] == 43 ? 1 : 0 \t\t\t        || m[y + 1][x] == 43 ? 1 : 0) ? 43 : 45); \t    for (int y = 0; y &lt; 616; y++) \t        for (int x = 0; x &lt; 1220; x++) \t\t    x_[y][x] = 0; \t    for (int y = 0; y &lt; 19; y++) \t        for (int x = 0; x &lt; 19; x++) \t\t    d_(((m[y][x] &gt;&gt; 4) &amp; 1) &lt;&lt; 2 | (m[y][x] &amp; 3), x, y); \t    for (int y = 0; y &lt; 19; y++) \t        for (int x = 0; x &lt; 19; x++)     \t\tif ((x % 14 == 2) &amp;&amp; (y % 4 == 3)) \t    \t    d_(7, x, y);     \tfor (int y = 0; y &lt; 616; y++) \t        for (int x = 0; x &lt; 1220; x++) { \t    \t    x_[y][x] &amp;= 14737632 | (31 &lt;&lt; ((x % 3) &lt;&lt; 3)); \t    \t    x_[y][x] += 986895 &amp; (rn *= 16777619); \t        } \t    XPutImage(d, w, (*(long *)((char *) (*(long *) ((char *)d + 232)) +\t72)), M, 0, 0, 0, 0, 1220, 616); \t    XMapWindow(d, w); \t    XFlush(d); \t    syscall(35, &amp;N, &amp;R);     }      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<h4>Syscalls<\/h4>\n<p>  \u0417\u0430\u043c\u0435\u043d\u0438\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u043f\u043e \u0442\u043e\u043c\u0443 \u0436\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u044b \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u0438 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438:  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u0434 \u0431\u0435\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;X11\/Xlib.h&gt; #include &lt;sys\/types.h&gt; #include &lt;sys\/stat.h&gt; #include &lt;fcntl.h&gt; #include &lt;unistd.h&gt;  int _x[] = { 15117427, 8413248, 5878632, 13027014, 1 };  int x_[616][1220]; char m[19][20]; long w; int rn = 2166136261, _[8][40][64] = { 0 };  void *M, *d, *T;  void b(int t, int x, int y, int c, int l) {     if ((x &gt;= 19 || y &gt;= 19 || x &lt; 0 || y &lt; 0) || (m[y][x] == l) \t|| (m[y][x] != c)) \treturn;     m[y][x] = l;     b(t, x - 1, y, c, l);     b(t, x + 1, y, c, l);     b(t, x, y - 1, c, l);     b(t, x, y + 1, c, l); }  void e(int t, int x, int y, int c, int l) {     if ((x &gt;= 64 || y &gt;= 40 || x &lt; 0 || y &lt; 0) || (_[t][y][x] == l) \t|| (_[t][y][x] != c)) \treturn;     _[t][y][x] = l;     e(t, x - 1, y, c, l);     e(t, x + 1, y, c, l);     e(t, x, y - 1, c, l);     e(t, x, y + 1, c, l); }  void k(int t, int x, int y, int c, int l) {     while (c--) { \t_[t][y][x++] = l; \t_[t][y++][x++] = l;     } }  void r(int t, int x, int y, int c, int l) {     while (c--) { \t_[t][y][x--] = l; \t_[t][y++][x--] = l;     } }  void u(int t, int x, int y, int c, int l) {     while (c--) \t_[t][y++][x] = l; }  char *z[8] = {      (char[]) {4},      (char[]) {6, 1 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16, 0, 0, \t\t     21 + 0 * 3 - 0, 16, 1, 63, 21 + 0 * 3 - 0, 16, 2, \t\t     63 * 0, 21 - 0, 4, 2, 31 + 0, 36 - 0, 4, 0 + 1, \t\t     32 - 1, 5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1, 63, \t\t     21 + 1 * 3 - 0, 16, 2, 63 * 1, 21 - 0, 4, 2, 31 + 1, \t\t     36 - 0, 4, 6, 1 * 4 + 0, 3, 31, 8 - 0, 6, 1 * 4 + 2, \t\t     3, 33, 38 - 0, 6, 1 * 4 + 3, 3, 30, 38 - 0, 4}, \t(char[]) {5, 1},  \t(char[]) {6, 0 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16, \t\t\t\t   0, 0, 21 + 0 * 3 - 0, 16, 1, 63, \t\t\t\t   21 + 0 * 3 - 0, 16, 2, 63 * 0, 21 - 0, \t\t\t\t   4, 2, 31 + 0, 36 - 0, 4, 0 + 1, 32 - 1, \t\t\t\t   5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1, \t\t\t\t   63, 21 + 1 * 3 - 0, 16, 2, 63 * 1, \t\t\t\t   21 - 0, 4, 2, 31 + 1, 36 - 0, 4, 6, \t\t\t\t   0 * 4 + 0, 3, 31, 8 - 0, 6, 0 * 4 + 2, \t\t\t\t   3, 33, 38 - 0, 6, 0 * 4 + 3, 3, 30, \t\t\t\t   38 - 0, \t\t\t\t   4}, \t(char[]) {4}, (char[]) {4}, \t(char[]) {6, 2 * 4 + 1, 0 + 0, 32 - 0, 5 - 3, 16, 0, 0, \t\t  21 + 0 * 3 - 3, 16, 1, 63, 21 + 0 * 3 - 3, 16, 2, 63 * 0, \t\t  21 - 3, 4, 2, 31 + 0, 36 - 3, 4, 0 + 1, 32 - 1, 5 - 3, \t\t  16, 0, 0, 21 + 1 * 3 - 3, 16, 1, 63, 21 + 1 * 3 - 3, 16, \t\t  2, 63 * 1, 21 - 3, 4, 2, 31 + 1, 36 - 3, 4, 6, 2 * 4 + 0, \t\t  3, 31, 8 - 3, 6, 2 * 4 + 2, 3, 33, 38 - 3, 6, 2 * 4 + 3, \t\t  3, 30, 38 - 3, 4},      (char[]) {6, 13, 0, 32, 9 + 0, 12 - 0, \t\t\t\t\t       0, 8 + 0 + 0, 21, 12 - 0, 1, \t\t\t\t\t       31, 9 + 0, 12 - 0, 1, \t\t\t\t\t       55 - 0 - 0, 21, 12 - 0, 0, \t\t\t\t\t       32, 9 + 3, 12 - 3, 0, \t\t\t\t\t       8 + 3 + 3, 21, 12 - 3, 1, \t\t\t\t\t       31, 9 + 3, 12 - 3, 1, \t\t\t\t\t       55 - 3 - 3, 21, 12 - 3, 6, \t\t\t\t\t       14 + 0, 2, 31 + 0, 13, 4, \t\t\t\t\t       1 - 0, 31 + 0, 16, 7, 3, \t\t\t\t\t       30 + 3 * 0, 14, 6, \t\t\t\t\t       12 + 0 * 4, 3, 32 - 0, \t\t\t\t\t       11 + 0 * 8, 6, 14 + 1, 2, \t\t\t\t\t       31 + 1, 13, 4, 1 - 1, \t\t\t\t\t       31 + 1, 16, 7, 3, \t\t\t\t\t       30 + 3 * 1, 14, 6, \t\t\t\t\t       12 + 1 * 4, 3, 32 - 1, \t\t\t\t\t       11 + 1 * 8, \t\t\t\t\t       4} };  void d_(int t, int p, int q) {     for (int y = 0; y &lt; 40; y++) \tfor (int x = 0; x &lt; 64; x++) \t    if (_[t] \t\t[y][x]) \t\tx_[y + q * 16 + p * 16][x + 580 + p * 32 - q * \t\t\t\t\t32] = _[t][y][x]; }  int main(int a, char *s[]) {     d = XOpenDisplay(0);     w = XCreateSimpleWindow(d, (*(long *) ((char *) (*(long *) ((char *)d + 232)) + 16)), 0, 0, 1220, 616, 1, 0, 0);     M = XCreateImage(d, (*(long *)((char *) (*(long *) ((char *)d + 232)) + 64)), (*(long *)((char *) (*(long *) ((char *)d + 232)) + 56)), 2, 0, (char *) x_, 1220, 616, 32, 0);     for (int i = 0; i &lt; 8; i++) { \t    char *p = z[i]; \t    int c = 0; \t    while (*p != 4) { \t        switch (*p) { \t        case 0: \t    \t    k(i, p[1], p[2], p[3], c); \t    \t    p += 4; \t    \t    break; \t        case 1: \t    \t    r(i, p[1], p[2], p[3], c); \t    \t    p += 4; \t    \t    break; \t        case 2: \t    \t    u(i, p[1], p[2], p[3], c); \t    \t    p += 4; \t    \t    break; \t        case 3: \t    \t    e(i, p[1] \t    \t      , p[2], 0, c); \t    \t    p += 3; \t    \t    break; \t        case 5: \t    \t    p = z[p[1]]; \t    \t    break; \t        case 6: \t    \t    c = _x[p[1] \/ 4] - 1643277 * (p[1] % 4); \t    \t    p += 2; \t    \t    break; \t        } \t    }     }     while (a++) { \t    int f = open(s[1], 0); \t    read(f, m, 380); \t    close(f); \t     \t     \t    for (int y = 0; y &lt; 19; y++) \t        for (int x = 0; x &lt; 19; x++) \t\t    if ((x % 14 == 2) &amp;&amp; (y % 4 == 3)) \t\t        m[y][x] = 46; \t    b(0, 2, 3, m[3][2], a &amp; 1 ? 43 : 45); \t    b(0, 2, 7, m[7][2], a &amp; 2 ? 43 : 45); \t    b(0, 2, 11, m[11][2], a &amp; 4 ? 43 : 45); \t    b(0, 2, 15, m[15][2], a &amp; 8 ? 43 : 45); \t    for (int i = 0; i &lt; 20; i++) \t        for (int y = 0; y &lt; 19; y++) \t\t    for (int x = 0; x &lt; 19; x++) \t\t        if (m[y][x] == 62) \t\t\t    b(0, x + 1, y, m[y][x + 1], \t\t\t    !(m[y - 1][x] == 43 ? 1 : 0 \t\t\t        || m[y + 1][x] == 43 ? 1 : 0) ? 43 : 45); \t    for (int y = 0; y &lt; 616; y++) \t        for (int x = 0; x &lt; 1220; x++) \t\t    x_[y][x] = 0; \t    for (int y = 0; y &lt; 19; y++) \t        for (int x = 0; x &lt; 19; x++) \t\t    d_(((m[y][x] &gt;&gt; 4) &amp; 1) &lt;&lt; 2 | (m[y][x] &amp; 3), x, y); \t    for (int y = 0; y &lt; 19; y++) \t        for (int x = 0; x &lt; 19; x++)     \t\tif ((x % 14 == 2) &amp;&amp; (y % 4 == 3)) \t    \t    d_(7, x, y);     \tfor (int y = 0; y &lt; 616; y++) \t        for (int x = 0; x &lt; 1220; x++) { \t    \t    x_[y][x] &amp;= 14737632 | (31 &lt;&lt; ((x % 3) &lt;&lt; 3)); \t    \t    x_[y][x] += 986895 &amp; (rn *= 16777619); \t        } \t    XPutImage(d, w, (*(long *)((char *) (*(long *) ((char *)d + 232)) +\t72)), M, 0, 0, 0, 0, 1220, 616); \t    XMapWindow(d, w); \t    XFlush(d); \t     \t    sleep(1);     }      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<h4>XCreateSimpleWindow \u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f<\/h4>\n<p>  \u041f\u043e\u0441\u0442\u0430\u0440\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e:  <\/p>\n<pre><code class=\"cpp\">w = XCreateSimpleWindow(d, (*(long *) ((char *) (*(long *) ((char *)d + 232)) + 16)), 0, 0, 1220, 616, 1, 0, 0);<\/code><\/pre>\n<p>  \u041a\u0443\u0447\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439 \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043d\u0443\u0436\u043d\u044b \u043b\u0438\u0448\u044c \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0442\u0430\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f, \u043e\u0434\u043d\u0430\u043a\u043e \u043a\u0430\u0436\u0434\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0434\u0435\u0441\u044c \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u044e \u0446\u0435\u043b\u044c, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e:<br \/>  d \u2014 \u044d\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 Display \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 Xlib. \u041e\u043d \u0438\u043c\u0435\u0435\u0442 \u043f\u043e\u043b\u0435-\u043c\u0430\u0441\u0441\u0438\u0432, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0435 screens \u0438 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0442\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442 (\u043d\u0430 x64 \u2014 232) \u043e\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 Display \u0432\u043f\u0435\u0440\u0435\u0434. \u0422\u0430\u043a \u043a\u0430\u043a Display \u043d\u0435 char *, \u0442\u043e \u043f\u0440\u0438 \u043f\u0440\u044f\u043c\u043e\u043c \u043e\u0442\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0438 \u043c\u044b \u043e\u0431\u0441\u0447\u0438\u0442\u0430\u043b\u0438\u0441\u044c \u0431\u044b \u0432 sizeof(long *) \u0431\u0430\u0439\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c d \u043a char * \u0438 \u0441\u0434\u0432\u0438\u043d\u0435\u043c\u0441\u044f \u043d\u0430 232 \u0431\u0430\u0439\u0442\u0430:  <\/p>\n<pre><code class=\"cpp\"> ((char *)d + 232)<\/code><\/pre>\n<p>  \u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 Screens \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u0435\u0433\u043e \u043a \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u043c\u0443 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e \u0438 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u0443\u0435\u043c:  <\/p>\n<pre><code class=\"cpp\">(*(long *) ((char *)d + 232))<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b Screens \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0435 \u043e\u043a\u043d\u043e, Root. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u0442\u043e\u0439\u0434\u0435\u043c \u043e\u0442 Screens \u043d\u0430 16 \u0431\u0430\u0439\u0442 \u0438 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u0443\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e:  <\/p>\n<pre><code class=\"cpp\">(*(long *) ((char *) (*(long *) ((char *)d + 232)) + 16))<\/code><\/pre>\n<p>  \u042d\u0442\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430\u043c\u0438 \u043f\u043e\u0434 Xlib, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0435\u0451 \u043e\u0431\u0449\u0435\u0443\u043f\u043e\u0442\u0440\u0435\u0431\u0438\u043c\u044b\u0439 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442 \u2014 \u044d\u0442\u043e <\/p>\n<pre><code class=\"cpp\">RootWindow(Display, DefaultScreen(Display))<\/code><\/pre>\n<p>  \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 \u0433\u043b\u0430\u0437\u0443 \u043c\u0430\u043a\u0440\u043e\u0441\u044b (\u0437\u0430\u043e\u0434\u043d\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u043c \u043a\u043e\u0441\u044f\u043a\u0438 indent):  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043c\u0435\u043d\u044b \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0439:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\"> #include &lt;X11\/Xlib.h&gt; #include &lt;sys\/types.h&gt; #include &lt;sys\/stat.h&gt; #include &lt;fcntl.h&gt; #include &lt;unistd.h&gt;  int _x[] = { 15117427, 8413248, 5878632, 13027014, 1 };  int x_[616][1220]; char m[19][20]; int rn = 2166136261, _[8][40][64] = { 0 };  void *T;  Display * display; Window window; XImage * image;  void b(int t, int x, int y, int c, int l) {     if ((x &gt;= 19 || y &gt;= 19 || x &lt; 0 || y &lt; 0) || (m[y][x] == l)     || (m[y][x] != c))     return;     m[y][x] = l;     b(t, x - 1, y, c, l);     b(t, x + 1, y, c, l);     b(t, x, y - 1, c, l);     b(t, x, y + 1, c, l); }  void e(int t, int x, int y, int c, int l) {     if ((x &gt;= 64 || y &gt;= 40 || x &lt; 0 || y &lt; 0) || (_[t][y][x] == l)         || (_[t][y][x] != c))         return;     _[t][y][x] = l;     e(t, x - 1, y, c, l);     e(t, x + 1, y, c, l);     e(t, x, y - 1, c, l);     e(t, x, y + 1, c, l); }  void k(int t, int x, int y, int c, int l) {     while (c--) {         _[t][y][x++] = l;         _[t][y++][x++] = l;     } }  void r(int t, int x, int y, int c, int l) {     while (c--) {         _[t][y][x--] = l;         _[t][y++][x--] = l;     } }  void u(int t, int x, int y, int c, int l) {     while (c--)         _[t][y++][x] = l; }  char *z[8] = {      (char[]) {4},      (char[]) {6, 1 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16, 0, 0,               21 + 0 * 3 - 0, 16, 1, 63, 21 + 0 * 3 - 0, 16, 2,               63 * 0, 21 - 0, 4, 2, 31 + 0, 36 - 0, 4, 0 + 1,               32 - 1, 5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1, 63,               21 + 1 * 3 - 0, 16, 2, 63 * 1, 21 - 0, 4, 2, 31 + 1,               36 - 0, 4, 6, 1 * 4 + 0, 3, 31, 8 - 0, 6, 1 * 4 + 2,               3, 33, 38 - 0, 6, 1 * 4 + 3, 3, 30, 38 - 0, 4},     (char[]) {5, 1},      (char[]) {6, 0 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16,               0, 0, 21 + 0 * 3 - 0, 16, 1, 63,               21 + 0 * 3 - 0, 16, 2, 63 * 0, 21 - 0,               4, 2, 31 + 0, 36 - 0, 4, 0 + 1, 32 - 1,               5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1,               63, 21 + 1 * 3 - 0, 16, 2, 63 * 1,               21 - 0, 4, 2, 31 + 1, 36 - 0, 4, 6,               0 * 4 + 0, 3, 31, 8 - 0, 6, 0 * 4 + 2,               3, 33, 38 - 0, 6, 0 * 4 + 3, 3, 30,               38 - 0,               4},     (char[]) {4},      (char[]) {4},     (char[]) {6, 2 * 4 + 1, 0 + 0, 32 - 0, 5 - 3, 16, 0, 0,               21 + 0 * 3 - 3, 16, 1, 63, 21 + 0 * 3 - 3, 16, 2, 63 * 0,               21 - 3, 4, 2, 31 + 0, 36 - 3, 4, 0 + 1, 32 - 1, 5 - 3,               16, 0, 0, 21 + 1 * 3 - 3, 16, 1, 63, 21 + 1 * 3 - 3, 16,               2, 63 * 1, 21 - 3, 4, 2, 31 + 1, 36 - 3, 4, 6, 2 * 4 + 0,               3, 31, 8 - 3, 6, 2 * 4 + 2, 3, 33, 38 - 3, 6, 2 * 4 + 3,               3, 30, 38 - 3, 4},      (char[]) {6, 13, 0, 32, 9 + 0, 12 - 0,               0, 8 + 0 + 0, 21, 12 - 0, 1,               31, 9 + 0, 12 - 0, 1,               55 - 0 - 0, 21, 12 - 0, 0,               32, 9 + 3, 12 - 3, 0,               8 + 3 + 3, 21, 12 - 3, 1,               31, 9 + 3, 12 - 3, 1,               55 - 3 - 3, 21, 12 - 3, 6,               14 + 0, 2, 31 + 0, 13, 4,               1 - 0, 31 + 0, 16, 7, 3,               30 + 3 * 0, 14, 6,               12 + 0 * 4, 3, 32 - 0,               11 + 0 * 8, 6, 14 + 1, 2,               31 + 1, 13, 4, 1 - 1,               31 + 1, 16, 7, 3,               30 + 3 * 1, 14, 6,               12 + 1 * 4, 3, 32 - 1,               11 + 1 * 8,               4} };  void d_(int t, int p, int q) {     for (int y = 0; y &lt; 40; y++)     for (int x = 0; x &lt; 64; x++)         if (_[t][y][x])             x_[y + q * 16 + p * 16][x + 580 + p * 32 - q * 32] = _[t][y][x]; }  int main(int a, char *s[]) {     display = XOpenDisplay(0);     window = XCreateSimpleWindow(display,                                   RootWindow(display, DefaultScreen(display)),                                   0, 0, 1220, 616, 1, 0, 0);     image = XCreateImage(display,                       DefaultVisual(display, DefaultScreen(display)),                       DefaultDepth(display, DefaultScreen(display)),                      2, 0, (char *) x_, 1220, 616, 32, 0);     for (int i = 0; i &lt; 8; i++) {         char *p = z[i];         int c = 0;         while (*p != 4) {             switch (*p) {             case 0:                 k(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 1:                 r(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 2:                 u(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 3:                 e(i, p[1]                   , p[2], 0, c);                 p += 3;                 break;             case 5:                 p = z[p[1]];                 break;             case 6:                 c = _x[p[1] \/ 4] - 1643277 * (p[1] % 4);                 p += 2;                 break;             }         }     }     while (a++) {         int f = open(s[1], 0);         read(f, m, 380);         close(f);                           for (int y = 0; y &lt; 19; y++)             for (int x = 0; x &lt; 19; x++)                 if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                     m[y][x] = 46;         b(0, 2, 3, m[3][2], a &amp; 1 ? 43 : 45);         b(0, 2, 7, m[7][2], a &amp; 2 ? 43 : 45);         b(0, 2, 11, m[11][2], a &amp; 4 ? 43 : 45);         b(0, 2, 15, m[15][2], a &amp; 8 ? 43 : 45);         for (int i = 0; i &lt; 20; i++)             for (int y = 0; y &lt; 19; y++)                 for (int x = 0; x &lt; 19; x++)                     if (m[y][x] == 62)                         b(0, x + 1, y, m[y][x + 1],                             !(m[y - 1][x] == 43 ? 1 : 0                             || m[y + 1][x] == 43 ? 1 : 0) ? 43 : 45);         for (int y = 0; y &lt; 616; y++)             for (int x = 0; x &lt; 1220; x++)                 x_[y][x] = 0;         for (int y = 0; y &lt; 19; y++)             for (int x = 0; x &lt; 19; x++)                 d_(((m[y][x] &gt;&gt; 4) &amp; 1) &lt;&lt; 2 | (m[y][x] &amp; 3), x, y);         for (int y = 0; y &lt; 19; y++)             for (int x = 0; x &lt; 19; x++)                 if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                     d_(7, x, y);         for (int y = 0; y &lt; 616; y++)             for (int x = 0; x &lt; 1220; x++) {                 x_[y][x] &amp;= 14737632 | (31 &lt;&lt; ((x % 3) &lt;&lt; 3));                 x_[y][x] += 986895 &amp; (rn *= 16777619);             }         XPutImage(display, window,                    DefaultGC(display, DefaultScreen(display)),                    image, 0, 0, 0, 0, 1220, 616);         XMapWindow(display, window);         XFlush(display);                  sleep(1);     }      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<h4>\u0414\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/h4>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e XCreateImage \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u0438, \u0433\u0434\u0435 \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439. \u0414\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u00abx_\u00bb. \u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0435\u043c \u0435\u0435 \u0432 pixdata \u0438 \u043d\u0430\u0439\u0434\u0435\u043c \u0432\u0441\u0435 \u043c\u0435\u0441\u0442\u0430, \u0433\u0434\u0435 \u043e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f:  <\/p>\n<pre><code class=\"cpp\">void d_(int t, int p, int q) {     for (int y = 0; y &lt; 40; y++)     for (int x = 0; x &lt; 64; x++)         if (_[t][y][x])             pixdata[y + q * 16 + p * 16][x + 580 + p * 32 - q * 32] = _[t][y][x]; \/\/ \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 }<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"cpp\">    image = XCreateImage(display,                       DefaultVisual(display, DefaultScreen(display)),                       DefaultDepth(display, DefaultScreen(display)),                      2, 0, (char *) pixdata, 1220, 616, 32, 0); \/\/ \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"cpp\">        for (int y = 0; y &lt; 616; y++)             for (int x = 0; x &lt; 1220; x++)                 pixdata[y][x] = 0; \/\/ &quot;\u041e\u0431\u043d\u0443\u043b\u0435\u043d\u0438\u0435&quot; \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u0437\u0430\u043a\u0440\u0430\u0441\u043a\u0430 \u0447\u0435\u0440\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"cpp\">        for (int y = 0; y &lt; 616; y++)             for (int x = 0; x &lt; 1220; x++) { \/\/ \u041a\u0430\u043a\u0430\u044f-\u0442\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u0430\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u0430\u044f \u043a\u043e \u0432\u0441\u0435\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e.                 pixdata[y][x] &amp;= 14737632 | (31 &lt;&lt; ((x % 3) &lt;&lt; 3));                 pixdata[y][x] += 986895 &amp; (rn *= 16777619);             }<\/code><\/pre>\n<p>  \u0412\u044b\u0447\u043b\u0435\u043d\u0438\u043c \u0431\u043b\u043e\u043a pixdata[..] = 0 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c, \u0447\u0442\u043e \u0436\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0435\u0440\u0432\u043e\u0435 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435:  <\/p>\n<pre><code class=\"cpp\">    for (int y = 0; y &lt; 40; y++)     for (int x = 0; x &lt; 64; x++)         if (_[t][y][x])             pixdata[y + q * 16 + p * 16][x + 580 + p * 32 - q * 32] = _[t][y][x];<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c\u0441\u044f \u043a \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e, \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0442\u043e \u043b\u0435\u0433\u043a\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e 40 \u0438 64 \u2014 \u044d\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u00ab\u0431\u043b\u043e\u043a\u0430\u00bb, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0441\u0445\u0435\u043c\u0430. <br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/8m\/wk\/1a\/8mwk1aslumxzp0qjw-mzzsnh0ss.png\"><br \/>  \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0438\u0441\u0443\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u00ab\u0442\u0430\u0439\u043b\u00bb \u043d\u0430 \u043a\u0430\u043d\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0430 \u0441\u0443\u0434\u044f \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 &quot;_&quot; \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u00abt\u00bb \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0438\u043d\u0434\u0435\u043a\u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0430 p \u0438 q \u2014 \u0437\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b x \u0438 y. \u0417\u0430\u043e\u0434\u043d\u043e \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0435\u043c &quot;_&quot; \u0432 textures:  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u0434 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\"> #include &lt;X11\/Xlib.h&gt; #include &lt;sys\/types.h&gt; #include &lt;sys\/stat.h&gt; #include &lt;fcntl.h&gt; #include &lt;unistd.h&gt;  \/* \u041a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_WIDTH *1220) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_HEIGHT (616)  \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u043a\u0441\u0442\u0443\u0440 *\/ #define TEXTURE_COUNT (8) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_HEIGHT (40)  \/*! \\brief \u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.  * \u0422\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043a int \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 *\/ int pixdata[IMAGE_HEIGHT][IMAGE_WIDTH]; int textures[TEXTURE_COUNT][TEXTURE_HEIGHT][TEXTURE_WIDTH] = { 0 };  \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0438\u0441\u043f\u043b\u0435\u044f Xlib *\/ Display * display; \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430 Xlib *\/ Window window; \/*! \\brief \u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d *\/ XImage * image;  \/* \\brief \u041e\u0431\u043d\u0443\u043b\u044f\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044f \u0435\u0433\u043e \u0447\u0435\u0440\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c *\/ static void _image_reset(void) {     for (int y = 0; y &lt; IMAGE_HEIGHT; y++)         for (int x = 0; x &lt; IMAGE_WIDTH; x++)             pixdata[y][x] = 0; }  \/*! \\brief \u041e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u0445\u043e\u043b\u0441\u0442\u0435 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430  * \\param[in] y Y \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430 *\/ void _texture_draw(int t, int x, int y) {     for (int ty = 0; ty &lt; TEXTURE_HEIGHT; ty++)         for (int tx = 0; tx &lt; TEXTURE_WIDTH; tx++)             if (textures[t][ty][tx])                 pixdata[ty + y * 16 + x * 16]                        [tx + 580 + x * 32 - y * 32] = textures[t][ty][tx]; }  \/* \u041a\u043e\u0434 \u0434\u043e \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  int _x[] = { 15117427, 8413248, 5878632, 13027014, 1 };  char m[19][20]; int rn = 2166136261;  void *T;  void b(int t, int x, int y, int c, int l) {     if ((x &gt;= 19 || y &gt;= 19 || x &lt; 0 || y &lt; 0) || (m[y][x] == l)     || (m[y][x] != c))     return;     m[y][x] = l;     b(t, x - 1, y, c, l);     b(t, x + 1, y, c, l);     b(t, x, y - 1, c, l);     b(t, x, y + 1, c, l); }  void e(int t, int x, int y, int c, int l) {     if ((x &gt;= TEXTURE_WIDTH || y &gt;= TEXTURE_HEIGHT ||           x &lt; 0 || y &lt; 0) ||           (textures[t][y][x] == l) ||           (textures[t][y][x] != c))         return;     textures[t][y][x] = l;     e(t, x - 1, y, c, l);     e(t, x + 1, y, c, l);     e(t, x, y - 1, c, l);     e(t, x, y + 1, c, l); }  void k(int t, int x, int y, int c, int l) {     while (c--) {         textures[t][y][x++] = l;         textures[t][y++][x++] = l;     } }  void r(int t, int x, int y, int c, int l) {     while (c--) {         textures[t][y][x--] = l;         textures[t][y++][x--] = l;     } }  void u(int t, int x, int y, int c, int l) {     while (c--)         textures[t][y++][x] = l; }  char *z[8] = {      (char[]) {4},      (char[]) {6, 1 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16, 0, 0,               21 + 0 * 3 - 0, 16, 1, 63, 21 + 0 * 3 - 0, 16, 2,               63 * 0, 21 - 0, 4, 2, 31 + 0, 36 - 0, 4, 0 + 1,               32 - 1, 5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1, 63,               21 + 1 * 3 - 0, 16, 2, 63 * 1, 21 - 0, 4, 2, 31 + 1,               36 - 0, 4, 6, 1 * 4 + 0, 3, 31, 8 - 0, 6, 1 * 4 + 2,               3, 33, 38 - 0, 6, 1 * 4 + 3, 3, 30, 38 - 0, 4},     (char[]) {5, 1},      (char[]) {6, 0 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16,               0, 0, 21 + 0 * 3 - 0, 16, 1, 63,               21 + 0 * 3 - 0, 16, 2, 63 * 0, 21 - 0,               4, 2, 31 + 0, 36 - 0, 4, 0 + 1, 32 - 1,               5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1,               63, 21 + 1 * 3 - 0, 16, 2, 63 * 1,               21 - 0, 4, 2, 31 + 1, 36 - 0, 4, 6,               0 * 4 + 0, 3, 31, 8 - 0, 6, 0 * 4 + 2,               3, 33, 38 - 0, 6, 0 * 4 + 3, 3, 30,               38 - 0,               4},     (char[]) {4},      (char[]) {4},     (char[]) {6, 2 * 4 + 1, 0 + 0, 32 - 0, 5 - 3, 16, 0, 0,               21 + 0 * 3 - 3, 16, 1, 63, 21 + 0 * 3 - 3, 16, 2, 63 * 0,               21 - 3, 4, 2, 31 + 0, 36 - 3, 4, 0 + 1, 32 - 1, 5 - 3,               16, 0, 0, 21 + 1 * 3 - 3, 16, 1, 63, 21 + 1 * 3 - 3, 16,               2, 63 * 1, 21 - 3, 4, 2, 31 + 1, 36 - 3, 4, 6, 2 * 4 + 0,               3, 31, 8 - 3, 6, 2 * 4 + 2, 3, 33, 38 - 3, 6, 2 * 4 + 3,               3, 30, 38 - 3, 4},      (char[]) {6, 13, 0, 32, 9 + 0, 12 - 0,               0, 8 + 0 + 0, 21, 12 - 0, 1,               31, 9 + 0, 12 - 0, 1,               55 - 0 - 0, 21, 12 - 0, 0,               32, 9 + 3, 12 - 3, 0,               8 + 3 + 3, 21, 12 - 3, 1,               31, 9 + 3, 12 - 3, 1,               55 - 3 - 3, 21, 12 - 3, 6,               14 + 0, 2, 31 + 0, 13, 4,               1 - 0, 31 + 0, 16, 7, 3,               30 + 3 * 0, 14, 6,               12 + 0 * 4, 3, 32 - 0,               11 + 0 * 8, 6, 14 + 1, 2,               31 + 1, 13, 4, 1 - 1,               31 + 1, 16, 7, 3,               30 + 3 * 1, 14, 6,               12 + 1 * 4, 3, 32 - 1,               11 + 1 * 8,               4} };  int main(int a, char *s[]) {     display = XOpenDisplay(0);     window = XCreateSimpleWindow(display,                                   RootWindow(display, DefaultScreen(display)),                                   0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, 1, 0, 0);     image = XCreateImage(display,                       DefaultVisual(display, DefaultScreen(display)),                       DefaultDepth(display, DefaultScreen(display)),                      2, 0, (char *) pixdata, IMAGE_WIDTH, IMAGE_HEIGHT, 32, 0);     for (int i = 0; i &lt; 8; i++) {         char *p = z[i];         int c = 0;         while (*p != 4) {             switch (*p) {             case 0:                 k(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 1:                 r(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 2:                 u(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 3:                 e(i, p[1]                   , p[2], 0, c);                 p += 3;                 break;             case 5:                 p = z[p[1]];                 break;             case 6:                 c = _x[p[1] \/ 4] - 1643277 * (p[1] % 4);                 p += 2;                 break;             }         }     }     while (a++) {         int f = open(s[1], 0);         read(f, m, 380);         close(f);                  for (int y = 0; y &lt; 19; y++)             for (int x = 0; x &lt; 19; x++)                 if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                     m[y][x] = 46;         b(0, 2, 3, m[3][2], a &amp; 1 ? 43 : 45);         b(0, 2, 7, m[7][2], a &amp; 2 ? 43 : 45);         b(0, 2, 11, m[11][2], a &amp; 4 ? 43 : 45);         b(0, 2, 15, m[15][2], a &amp; 8 ? 43 : 45);         for (int i = 0; i &lt; 20; i++)             for (int y = 0; y &lt; 19; y++)                 for (int x = 0; x &lt; 19; x++)                     if (m[y][x] == 62)                         b(0, x + 1, y, m[y][x + 1],                             !(m[y - 1][x] == 43 ? 1 : 0                             || m[y + 1][x] == 43 ? 1 : 0) ? 43 : 45);                  _image_reset();                    for (int y = 0; y &lt; 19; y++)             for (int x = 0; x &lt; 19; x++)                 _texture_draw(((m[y][x] &gt;&gt; 4) &amp; 1) &lt;&lt; 2 | (m[y][x] &amp; 3), x, y);                          for (int y = 0; y &lt; 19; y++)             for (int x = 0; x &lt; 19; x++)                 if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                     _texture_draw(7, x, y);         for (int y = 0; y &lt; IMAGE_HEIGHT; y++)             for (int x = 0; x &lt; IMAGE_WIDTH; x++) {                 pixdata[y][x] &amp;= 14737632 | (31 &lt;&lt; ((x % 3) &lt;&lt; 3));                 pixdata[y][x] += 986895 &amp; (rn *= 16777619);             }         XPutImage(display, window,                    DefaultGC(display, DefaultScreen(display)),                    image, 0, 0, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);         XMapWindow(display, window);         XFlush(display);                  sleep(1);     }      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<h4>\u0427\u0442\u0435\u043d\u0438\u0435 \u043a\u0430\u0440\u0442\u044b<\/h4>\n<p>  \u0412\u044b\u0434\u0435\u043b\u0438\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438 open..close, \u0433\u0434\u0435 \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e m (\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0435\u043c \u0432 mapdata).  <\/p>\n<blockquote><p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0444\u0430\u0439\u043b \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0446\u0438\u043a\u043b\u0435? \u0422\u0430\u043a \u0431\u044b\u043b\u043e \u043a\u043e\u0440\u043e\u0447\u0435 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0438 \u0442\u043e\u043a\u0435\u043d\u043e\u0432. \u041e\u043a\u043e\u043b\u043e 4 \u0434\u043d\u0435\u0439 \u0437\u0430\u043d\u044f\u043b \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u00ab\u0443\u0442\u0440\u0430\u043c\u0431\u043e\u0432\u044b\u0432\u0430\u043d\u0438\u044f\u00bb \u043a\u043e\u0434\u0430 \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u0432 \u043b\u0438\u043c\u0438\u0442\u044b \u043f\u0440\u0430\u0432\u0438\u043b. \u0415\u0441\u043b\u0438 \u0447\u0438\u0442\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0431\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0438 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0430\u043d\u0430\u043b\u043e\u0433 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 memcpy.<\/p><\/blockquote>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0412\u044b\u0434\u0435\u043b\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f _map_read<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;X11\/Xlib.h&gt; #include &lt;sys\/types.h&gt; #include &lt;sys\/stat.h&gt; #include &lt;fcntl.h&gt; #include &lt;unistd.h&gt;  \/* \u041a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_WIDTH (1220) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_HEIGHT (616) \/*! \\brief \u0421\u0434\u0432\u0438\u0433 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0433\u0440\u0430\u043d\u0438 \u043a\u0430\u0440\u0442\u044b \u043e\u0442 \u043b\u0435\u0432\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b *\/ #define IMAGE_SHIFTX (580)  \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u043a\u0441\u0442\u0443\u0440 *\/ #define TEXTURE_COUNT (8) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_HEIGHT (40) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0433\u0440\u0430\u043d\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_TOP_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0433\u0440\u0430\u043d\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_TOP_HEIGHT (32)  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f *\/ #define MAP_WIDTH (19) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f *\/ #define MAP_HEIGHT (19) \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435-\u0447\u0435\u0440\u0442\u0435\u0436\u0435. \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '\\n' *\/ #define MAP_FILEDATA ((MAP_WIDTH + 1) * MAP_HEIGHT)  \/*! \\brief \u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.  * \u0422\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043a int \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 *\/ int pixdata[IMAGE_HEIGHT][IMAGE_WIDTH]; \/*! \\brief \u0422\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0431\u043b\u043e\u043a\u043e\u0432, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u044b\u0445 \u043d\u0430 \u043f\u043e\u043b\u0435 *\/ int textures[TEXTURE_COUNT][TEXTURE_HEIGHT][TEXTURE_WIDTH] = { 0 }; \/*! \\brief \u0414\u0430\u043d\u043d\u044b\u0435 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f.   * \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '\\n' *\/ char mapdata[MAP_HEIGHT][MAP_WIDTH + 1];  \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0438\u0441\u043f\u043b\u0435\u044f Xlib *\/ Display * display; \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430 Xlib *\/ Window window; \/*! \\brief \u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d *\/ XImage * image;  \/* \\brief \u041e\u0431\u043d\u0443\u043b\u044f\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044f \u0435\u0433\u043e \u0447\u0435\u0440\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c *\/ static void _image_reset(void) {     for (int y = 0; y &lt; IMAGE_HEIGHT; y++)         for (int x = 0; x &lt; IMAGE_WIDTH; x++)             pixdata[y][x] = 0; }  \/*! \\brief \u041e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u0445\u043e\u043b\u0441\u0442\u0435 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430  * \\param[in] y Y \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430 *\/ static void _texture_draw(int t, int x, int y) {     for (int ty = 0; ty &lt; TEXTURE_HEIGHT; ty++)         for (int tx = 0; tx &lt; TEXTURE_WIDTH; tx++)             if (textures[t][ty][tx])                 pixdata[ty +                          y * (TEXTURE_TOP_HEIGHT \/ 2) +                          x * (TEXTURE_TOP_HEIGHT \/ 2)]                        [tx +                          IMAGE_SHIFTX +                          x * (TEXTURE_TOP_WIDTH \/ 2) -                          y * TEXTURE_TOP_HEIGHT] = textures[t][ty][tx]; }  \/*! \\brief \u0427\u0438\u0442\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430 \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043a\u0430\u0440\u0442\u0443   * \\param[in] filename \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430 *\/ static void _map_read(const char * filename) {     int f = open(filename, 0);     read(f, mapdata, MAP_FILEDATA);     close(f); }  \/* \u041a\u043e\u0434 \u0434\u043e \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  int _x[] = { 15117427, 8413248, 5878632, 13027014, 1 }; int rn = 2166136261;  void *T;  void b(int t, int x, int y, int c, int l) {     if ((x &gt;= MAP_WIDTH || y &gt;= MAP_HEIGHT ||           x &lt; 0 || y &lt; 0) || (mapdata[y][x] == l)         || (mapdata[y][x] != c))         return;     mapdata[y][x] = l;     b(t, x - 1, y, c, l);     b(t, x + 1, y, c, l);     b(t, x, y - 1, c, l);     b(t, x, y + 1, c, l); }  void e(int t, int x, int y, int c, int l) {     if ((x &gt;= TEXTURE_WIDTH || y &gt;= TEXTURE_HEIGHT ||           x &lt; 0 || y &lt; 0) ||           (textures[t][y][x] == l) ||           (textures[t][y][x] != c))         return;     textures[t][y][x] = l;     e(t, x - 1, y, c, l);     e(t, x + 1, y, c, l);     e(t, x, y - 1, c, l);     e(t, x, y + 1, c, l); }  void k(int t, int x, int y, int c, int l) {     while (c--) {         textures[t][y][x++] = l;         textures[t][y++][x++] = l;     } }  void r(int t, int x, int y, int c, int l) {     while (c--) {         textures[t][y][x--] = l;         textures[t][y++][x--] = l;     } }  void u(int t, int x, int y, int c, int l) {     while (c--)         textures[t][y++][x] = l; }  char *z[8] = {      (char[]) {4},      (char[]) {6, 1 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16, 0, 0,               21 + 0 * 3 - 0, 16, 1, 63, 21 + 0 * 3 - 0, 16, 2,               63 * 0, 21 - 0, 4, 2, 31 + 0, 36 - 0, 4, 0 + 1,               32 - 1, 5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1, 63,               21 + 1 * 3 - 0, 16, 2, 63 * 1, 21 - 0, 4, 2, 31 + 1,               36 - 0, 4, 6, 1 * 4 + 0, 3, 31, 8 - 0, 6, 1 * 4 + 2,               3, 33, 38 - 0, 6, 1 * 4 + 3, 3, 30, 38 - 0, 4},     (char[]) {5, 1},      (char[]) {6, 0 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16,               0, 0, 21 + 0 * 3 - 0, 16, 1, 63,               21 + 0 * 3 - 0, 16, 2, 63 * 0, 21 - 0,               4, 2, 31 + 0, 36 - 0, 4, 0 + 1, 32 - 1,               5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1,               63, 21 + 1 * 3 - 0, 16, 2, 63 * 1,               21 - 0, 4, 2, 31 + 1, 36 - 0, 4, 6,               0 * 4 + 0, 3, 31, 8 - 0, 6, 0 * 4 + 2,               3, 33, 38 - 0, 6, 0 * 4 + 3, 3, 30,               38 - 0,               4},     (char[]) {4},      (char[]) {4},     (char[]) {6, 2 * 4 + 1, 0 + 0, 32 - 0, 5 - 3, 16, 0, 0,               21 + 0 * 3 - 3, 16, 1, 63, 21 + 0 * 3 - 3, 16, 2, 63 * 0,               21 - 3, 4, 2, 31 + 0, 36 - 3, 4, 0 + 1, 32 - 1, 5 - 3,               16, 0, 0, 21 + 1 * 3 - 3, 16, 1, 63, 21 + 1 * 3 - 3, 16,               2, 63 * 1, 21 - 3, 4, 2, 31 + 1, 36 - 3, 4, 6, 2 * 4 + 0,               3, 31, 8 - 3, 6, 2 * 4 + 2, 3, 33, 38 - 3, 6, 2 * 4 + 3,               3, 30, 38 - 3, 4},      (char[]) {6, 13, 0, 32, 9 + 0, 12 - 0,               0, 8 + 0 + 0, 21, 12 - 0, 1,               31, 9 + 0, 12 - 0, 1,               55 - 0 - 0, 21, 12 - 0, 0,               32, 9 + 3, 12 - 3, 0,               8 + 3 + 3, 21, 12 - 3, 1,               31, 9 + 3, 12 - 3, 1,               55 - 3 - 3, 21, 12 - 3, 6,               14 + 0, 2, 31 + 0, 13, 4,               1 - 0, 31 + 0, 16, 7, 3,               30 + 3 * 0, 14, 6,               12 + 0 * 4, 3, 32 - 0,               11 + 0 * 8, 6, 14 + 1, 2,               31 + 1, 13, 4, 1 - 1,               31 + 1, 16, 7, 3,               30 + 3 * 1, 14, 6,               12 + 1 * 4, 3, 32 - 1,               11 + 1 * 8,               4} };  int main(int a, char *s[]) {     display = XOpenDisplay(0);     window = XCreateSimpleWindow(display,                                   RootWindow(display, DefaultScreen(display)),                                   0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, 1, 0, 0);     image = XCreateImage(display,                       DefaultVisual(display, DefaultScreen(display)),                       DefaultDepth(display, DefaultScreen(display)),                      2, 0, (char *) pixdata, IMAGE_WIDTH, IMAGE_HEIGHT, 32, 0);     for (int i = 0; i &lt; 8; i++) {         char *p = z[i];         int c = 0;         while (*p != 4) {             switch (*p) {             case 0:                 k(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 1:                 r(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 2:                 u(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 3:                 e(i, p[1]                   , p[2], 0, c);                 p += 3;                 break;             case 5:                 p = z[p[1]];                 break;             case 6:                 c = _x[p[1] \/ 4] - 1643277 * (p[1] % 4);                 p += 2;                 break;             }         }     }     while (a++) {         _map_read(s[1]);                  for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                     mapdata[y][x] = 46;         b(0, 2, 3, mapdata[3][2], a &amp; 1 ? 43 : 45);         b(0, 2, 7, mapdata[7][2], a &amp; 2 ? 43 : 45);         b(0, 2, 11, mapdata[11][2], a &amp; 4 ? 43 : 45);         b(0, 2, 15, mapdata[15][2], a &amp; 8 ? 43 : 45);         for (int i = 0; i &lt; 20; i++)             for (int y = 0; y &lt; MAP_HEIGHT; y++)                 for (int x = 0; x &lt; MAP_WIDTH; x++)                     if (mapdata[y][x] == 62)                         b(0, x + 1, y, mapdata[y][x + 1],                             !(mapdata[y - 1][x] == 43 ? 1 : 0                             || mapdata[y + 1][x] == 43 ? 1 : 0) ? 43 : 45);                  _image_reset();                    for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 _texture_draw(((m[y][x] &gt;&gt; 4) &amp; 1) &lt;&lt; 2 | (mapdata[y][x] &amp; 3), x, y);                          for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                     _texture_draw(7, x, y);         for (int y = 0; y &lt; IMAGE_HEIGHT; y++)             for (int x = 0; x &lt; IMAGE_WIDTH; x++) {                 pixdata[y][x] &amp;= 14737632 | (31 &lt;&lt; ((x % 3) &lt;&lt; 3));                 pixdata[y][x] += 986895 &amp; (rn *= 16777619);             }         XPutImage(display, window,                    DefaultGC(display, DefaultScreen(display)),                    image, 0, 0, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);         XMapWindow(display, window);         XFlush(display);                  sleep(1);     }      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0420\u0430\u0437 \u0443\u0436 \u043c\u044b \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e mapdata, \u043e\u0431\u0440\u0430\u0442\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0433\u0434\u0435 \u043e\u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u2014 \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u00abb\u00bb, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043f\u043e\u043a\u0430 \u0442\u0440\u043e\u0433\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0438 \u00abmain\u00bb \u0433\u0434\u0435, \u043e\u0431\u0440\u0430\u0442\u0438\u0432 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u00ab\u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u043d\u044b\u0445\u00bb \u0444\u0430\u0439\u043b\u043e\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433:  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u0441\u043b\u0435 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u043f\u043e mapdata<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\"> #include &lt;X11\/Xlib.h&gt; #include &lt;sys\/types.h&gt; #include &lt;sys\/stat.h&gt; #include &lt;fcntl.h&gt; #include &lt;unistd.h&gt;  \/* \u041a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_WIDTH (1220) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_HEIGHT (616) \/*! \\brief \u0421\u0434\u0432\u0438\u0433 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0433\u0440\u0430\u043d\u0438 \u043a\u0430\u0440\u0442\u044b \u043e\u0442 \u043b\u0435\u0432\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b *\/ #define IMAGE_SHIFTX (580)  \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u043a\u0441\u0442\u0443\u0440 *\/ #define TEXTURE_COUNT (8) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_HEIGHT (40) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0433\u0440\u0430\u043d\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_TOP_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0433\u0440\u0430\u043d\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_TOP_HEIGHT (32)  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f *\/ #define MAP_WIDTH (19) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f *\/ #define MAP_HEIGHT (19) \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435-\u0447\u0435\u0440\u0442\u0435\u0436\u0435. \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '\\n' *\/ #define MAP_FILEDATA ((MAP_WIDTH + 1) * MAP_HEIGHT) \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 NOR-\u0443\u0437\u043b\u043e\u0432 *\/ #define MAP_ITERATIONS (20)  \/*! \\brief \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0444\u0430\u0439\u043b\u0430-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 *\/ enum map_characters {     MAPCHAR_WIRE  = '.', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434            (ASCII = 46) *\/     MAPCHAR_PLUS  = '+', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434 (\u0435\u0441\u0442\u044c \u0442\u043e\u043a) (ASCII = 43) *\/     MAPCHAR_MINUS = '-', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434 (\u043d\u0435\u0442 \u0442\u043e\u043a\u0430) (ASCII = 45) *\/     MAPCHAR_NOR   = '&gt;', \/**&lt; NOR-\u044d\u043b\u0435\u043c\u0435\u043d\u0442       (ASCII = 62) *\/ }  \/*! \\brief \u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.  * \u0422\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043a int \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 *\/ int pixdata[IMAGE_HEIGHT][IMAGE_WIDTH]; \/*! \\brief \u0422\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0431\u043b\u043e\u043a\u043e\u0432, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u044b\u0445 \u043d\u0430 \u043f\u043e\u043b\u0435 *\/ int textures[TEXTURE_COUNT][TEXTURE_HEIGHT][TEXTURE_WIDTH] = { 0 }; \/*! \\brief \u0414\u0430\u043d\u043d\u044b\u0435 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f.   * \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '\\n' *\/ char mapdata[MAP_HEIGHT][MAP_WIDTH + 1];  \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0438\u0441\u043f\u043b\u0435\u044f Xlib *\/ Display * display; \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430 Xlib *\/ Window window; \/*! \\brief \u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d *\/ XImage * image;  \/* \\brief \u041e\u0431\u043d\u0443\u043b\u044f\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044f \u0435\u0433\u043e \u0447\u0435\u0440\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c *\/ static void _image_reset(void) {     for (int y = 0; y &lt; IMAGE_HEIGHT; y++)         for (int x = 0; x &lt; IMAGE_WIDTH; x++)             pixdata[y][x] = 0; }  \/*! \\brief \u041e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u0445\u043e\u043b\u0441\u0442\u0435 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430  * \\param[in] y Y \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430 *\/ static void _texture_draw(int t, int x, int y) {     for (int ty = 0; ty &lt; TEXTURE_HEIGHT; ty++)         for (int tx = 0; tx &lt; TEXTURE_WIDTH; tx++)             if (textures[t][ty][tx])                 pixdata[ty +                          y * (TEXTURE_TOP_HEIGHT \/ 2) +                          x * (TEXTURE_TOP_HEIGHT \/ 2)]                        [tx +                          IMAGE_SHIFTX +                          x * (TEXTURE_TOP_WIDTH \/ 2) -                          y * TEXTURE_TOP_HEIGHT] = textures[t][ty][tx]; }  \/*! \\brief \u0427\u0438\u0442\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430 \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043a\u0430\u0440\u0442\u0443   * \\param[in] filename \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430 *\/ static void _map_read(const char * filename) {     int f = open(filename, 0);     read(f, mapdata, MAP_FILEDATA);     close(f); }  \/*! \\brief \u0417\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0432\u0445\u043e\u0434\u044b \u0438\u0437 \u0444\u0430\u0439\u043b\u0430-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0432\u0445\u043e\u0434  * \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0430 \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0440\u043e\u043d\u0442\u0430 \u0432\u043e\u043b\u043d\u044b *\/ static void _map_wire_inputs(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)         for (int x = 0; x &lt; MAP_WIDTH; x++)             if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                 mapdata[y][x] = MAPCHAR_WIRE; }  \/*! \\brief \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432\u0445\u043e\u0434\u044b \u0441\u0445\u0435\u043c\u044b \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f  * \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430.  * \\param[in] counter \u0421\u0447\u0435\u0442\u0447\u0438\u043a *\/ static void _map_wire_counter(int counter) {     b(0, 2, 3,  mapdata[3][2],  counter &amp; 1 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     b(0, 2, 7,  mapdata[7][2],  counter &amp; 2 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     b(0, 2, 11, mapdata[11][2], counter &amp; 4 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     b(0, 2, 15, mapdata[15][2], counter &amp; 8 ? MAPCHAR_PLUS : MAPCHAR_MINUS); }  \/*! \\brief \u041f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u0440\u0430\u0441\u0447\u0435\u0442 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e (\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e) \u0442\u043e\u043a\u0430 \u043f\u043e\u0441\u043b\u0435 NOR-\u0443\u0437\u043b\u0430 *\/ static void _map_process_gates(void) {            for (int i = 0; i &lt; MAP_ITERATIONS; i++)         for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if (mapdata[y][x] == MAPCHAR_NOR)                     b(0, x + 1, y, mapdata[y][x + 1],                         !(mapdata[y - 1][x] == MAPCHAR_PLUS ? 1 : 0                        || mapdata[y + 1][x] == MAPCHAR_PLUS ? 1 : 0) ?                              MAPCHAR_PLUS : MAPCHAR_MINUS); }  \/* \u041a\u043e\u0434 \u0434\u043e \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  int _x[] = { 15117427, 8413248, 5878632, 13027014, 1 }; int rn = 2166136261;  void *T;  void b(int t, int x, int y, int c, int l) {     if ((x &gt;= MAP_WIDTH || y &gt;= MAP_HEIGHT ||           x &lt; 0 || y &lt; 0) || (mapdata[y][x] == l)         || (mapdata[y][x] != c))         return;     mapdata[y][x] = l;     b(t, x - 1, y, c, l);     b(t, x + 1, y, c, l);     b(t, x, y - 1, c, l);     b(t, x, y + 1, c, l); }  void e(int t, int x, int y, int c, int l) {     if ((x &gt;= TEXTURE_WIDTH || y &gt;= TEXTURE_HEIGHT ||           x &lt; 0 || y &lt; 0) ||           (textures[t][y][x] == l) ||           (textures[t][y][x] != c))         return;     textures[t][y][x] = l;     e(t, x - 1, y, c, l);     e(t, x + 1, y, c, l);     e(t, x, y - 1, c, l);     e(t, x, y + 1, c, l); }  void k(int t, int x, int y, int c, int l) {     while (c--) {         textures[t][y][x++] = l;         textures[t][y++][x++] = l;     } }  void r(int t, int x, int y, int c, int l) {     while (c--) {         textures[t][y][x--] = l;         textures[t][y++][x--] = l;     } }  void u(int t, int x, int y, int c, int l) {     while (c--)         textures[t][y++][x] = l; }  char *z[8] = {      (char[]) {4},      (char[]) {6, 1 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16, 0, 0,               21 + 0 * 3 - 0, 16, 1, 63, 21 + 0 * 3 - 0, 16, 2,               63 * 0, 21 - 0, 4, 2, 31 + 0, 36 - 0, 4, 0 + 1,               32 - 1, 5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1, 63,               21 + 1 * 3 - 0, 16, 2, 63 * 1, 21 - 0, 4, 2, 31 + 1,               36 - 0, 4, 6, 1 * 4 + 0, 3, 31, 8 - 0, 6, 1 * 4 + 2,               3, 33, 38 - 0, 6, 1 * 4 + 3, 3, 30, 38 - 0, 4},     (char[]) {5, 1},      (char[]) {6, 0 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16,               0, 0, 21 + 0 * 3 - 0, 16, 1, 63,               21 + 0 * 3 - 0, 16, 2, 63 * 0, 21 - 0,               4, 2, 31 + 0, 36 - 0, 4, 0 + 1, 32 - 1,               5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1,               63, 21 + 1 * 3 - 0, 16, 2, 63 * 1,               21 - 0, 4, 2, 31 + 1, 36 - 0, 4, 6,               0 * 4 + 0, 3, 31, 8 - 0, 6, 0 * 4 + 2,               3, 33, 38 - 0, 6, 0 * 4 + 3, 3, 30,               38 - 0,               4},     (char[]) {4},      (char[]) {4},     (char[]) {6, 2 * 4 + 1, 0 + 0, 32 - 0, 5 - 3, 16, 0, 0,               21 + 0 * 3 - 3, 16, 1, 63, 21 + 0 * 3 - 3, 16, 2, 63 * 0,               21 - 3, 4, 2, 31 + 0, 36 - 3, 4, 0 + 1, 32 - 1, 5 - 3,               16, 0, 0, 21 + 1 * 3 - 3, 16, 1, 63, 21 + 1 * 3 - 3, 16,               2, 63 * 1, 21 - 3, 4, 2, 31 + 1, 36 - 3, 4, 6, 2 * 4 + 0,               3, 31, 8 - 3, 6, 2 * 4 + 2, 3, 33, 38 - 3, 6, 2 * 4 + 3,               3, 30, 38 - 3, 4},      (char[]) {6, 13, 0, 32, 9 + 0, 12 - 0,               0, 8 + 0 + 0, 21, 12 - 0, 1,               31, 9 + 0, 12 - 0, 1,               55 - 0 - 0, 21, 12 - 0, 0,               32, 9 + 3, 12 - 3, 0,               8 + 3 + 3, 21, 12 - 3, 1,               31, 9 + 3, 12 - 3, 1,               55 - 3 - 3, 21, 12 - 3, 6,               14 + 0, 2, 31 + 0, 13, 4,               1 - 0, 31 + 0, 16, 7, 3,               30 + 3 * 0, 14, 6,               12 + 0 * 4, 3, 32 - 0,               11 + 0 * 8, 6, 14 + 1, 2,               31 + 1, 13, 4, 1 - 1,               31 + 1, 16, 7, 3,               30 + 3 * 1, 14, 6,               12 + 1 * 4, 3, 32 - 1,               11 + 1 * 8,               4} };  int main(int a, char *s[]) {     display = XOpenDisplay(0);     window = XCreateSimpleWindow(display,                                   RootWindow(display, DefaultScreen(display)),                                   0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, 1, 0, 0);     image = XCreateImage(display,                       DefaultVisual(display, DefaultScreen(display)),                       DefaultDepth(display, DefaultScreen(display)),                      2, 0, (char *) pixdata, IMAGE_WIDTH, IMAGE_HEIGHT, 32, 0);     for (int i = 0; i &lt; 8; i++) {         char *p = z[i];         int c = 0;         while (*p != 4) {             switch (*p) {             case 0:                 k(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 1:                 r(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 2:                 u(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 3:                 e(i, p[1]                   , p[2], 0, c);                 p += 3;                 break;             case 5:                 p = z[p[1]];                 break;             case 6:                 c = _x[p[1] \/ 4] - 1643277 * (p[1] % 4);                 p += 2;                 break;             }         }     }     while (a++) {         _map_read(s[1]);         _map_wire_inputs();         _map_wire_counter(a);         _map_process_gates();                  _image_reset();                    for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 _texture_draw(((mapdata[y][x] &gt;&gt; 4) &amp; 1) &lt;&lt; 2 | (mapdata[y][x] &amp; 3), x, y);                          for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                     _texture_draw(7, x, y);         for (int y = 0; y &lt; IMAGE_HEIGHT; y++)             for (int x = 0; x &lt; IMAGE_WIDTH; x++) {                 pixdata[y][x] &amp;= 14737632 | (31 &lt;&lt; ((x % 3) &lt;&lt; 3));                 pixdata[y][x] += 986895 &amp; (rn *= 16777619);             }         XPutImage(display, window,                    DefaultGC(display, DefaultScreen(display)),                    image, 0, 0, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);         XMapWindow(display, window);         XFlush(display);                  sleep(1);     }      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u00abmapdata\u00bb \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u0435\u0449\u0435 \u043d\u0430 \u0434\u0432\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u2014 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u00abb\u00bb:  <\/p>\n<pre><code class=\"cpp\">void b(int t, int x, int y, int c, int l) {     if ((x &gt;= MAP_WIDTH || y &gt;= MAP_HEIGHT ||           x &lt; 0 || y &lt; 0) || (mapdata[y][x] == l)         || (mapdata[y][x] != c))         return;     mapdata[y][x] = l;     b(t, x - 1, y, c, l);     b(t, x + 1, y, c, l);     b(t, x, y - 1, c, l);     b(t, x, y + 1, c, l); }<\/code><\/pre>\n<p>  \u0418 \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0431\u043b\u043e\u043a\u0435  <\/p>\n<pre><code class=\"cpp\">        for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 _texture_draw(((mapdata[y][x] &gt;&gt; 4) &amp; 1) &lt;&lt; 2 | (mapdata[y][x] &amp; 3), x, y);<\/code><\/pre>\n<p>  <\/p>\n<h4>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u00abb\u00bb<\/h4>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c\u0441\u044f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u00abb\u00bb, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043e\u043d\u0430 \u0434\u043e \u0431\u043e\u043b\u0438 \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Flood_fill\" rel=\"nofollow\">flood_fill<\/a>, \u0447\u0442\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u0435\u0435 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u2014 \u043e\u043d\u0430 \u00ab\u0437\u0430\u043b\u0438\u0432\u0430\u0435\u0442\u00bb \u00ab\u043f\u0440\u043e\u0432\u043e\u0434\u00bb \u043d\u0443\u0436\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c \u0444\u0440\u043e\u043d\u0442 \u0432\u043e\u043b\u043d\u044b \u0442\u043e\u043a\u0430 \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u043f\u0440\u043e\u0432\u043e\u0434\u0430. \u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0435\u043c \u0435\u0435 \u0438 \u0432\u044b\u043d\u0435\u0441\u0435\u043c \u0432 \u0431\u043b\u043e\u043a \u00abproduction ready\u00bb.  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">Flood fill<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;X11\/Xlib.h&gt; #include &lt;sys\/types.h&gt; #include &lt;sys\/stat.h&gt; #include &lt;fcntl.h&gt; #include &lt;unistd.h&gt;  \/* \u041a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_WIDTH (1220) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_HEIGHT (616) \/*! \\brief \u0421\u0434\u0432\u0438\u0433 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0433\u0440\u0430\u043d\u0438 \u043a\u0430\u0440\u0442\u044b \u043e\u0442 \u043b\u0435\u0432\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b *\/ #define IMAGE_SHIFTX (580)  \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u043a\u0441\u0442\u0443\u0440 *\/ #define TEXTURE_COUNT (8) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_HEIGHT (40) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0433\u0440\u0430\u043d\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_TOP_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0433\u0440\u0430\u043d\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_TOP_HEIGHT (32)  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f *\/ #define MAP_WIDTH (19) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f *\/ #define MAP_HEIGHT (19) \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435-\u0447\u0435\u0440\u0442\u0435\u0436\u0435. \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '\\n' *\/ #define MAP_FILEDATA ((MAP_WIDTH + 1) * MAP_HEIGHT) \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 NOR-\u0443\u0437\u043b\u043e\u0432 *\/ #define MAP_ITERATIONS (20)  \/*! \\brief \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0444\u0430\u0439\u043b\u0430-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 *\/ enum map_characters {     MAPCHAR_WIRE  = '.', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434            (ASCII = 46) *\/     MAPCHAR_PLUS  = '+', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434 (\u0435\u0441\u0442\u044c \u0442\u043e\u043a) (ASCII = 43) *\/     MAPCHAR_MINUS = '-', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434 (\u043d\u0435\u0442 \u0442\u043e\u043a\u0430) (ASCII = 45) *\/     MAPCHAR_NOR   = '&gt;', \/**&lt; NOR-\u044d\u043b\u0435\u043c\u0435\u043d\u0442       (ASCII = 62) *\/ };  \/*! \\brief \u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.  * \u0422\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043a int \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 *\/ int pixdata[IMAGE_HEIGHT][IMAGE_WIDTH]; \/*! \\brief \u0422\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0431\u043b\u043e\u043a\u043e\u0432, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u044b\u0445 \u043d\u0430 \u043f\u043e\u043b\u0435 *\/ int textures[TEXTURE_COUNT][TEXTURE_HEIGHT][TEXTURE_WIDTH] = { 0 }; \/*! \\brief \u0414\u0430\u043d\u043d\u044b\u0435 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f.   * \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '\\n' *\/ char mapdata[MAP_HEIGHT][MAP_WIDTH + 1];  \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0438\u0441\u043f\u043b\u0435\u044f Xlib *\/ Display * display; \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430 Xlib *\/ Window window; \/*! \\brief \u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d *\/ XImage * image;  \/* \\brief \u041e\u0431\u043d\u0443\u043b\u044f\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044f \u0435\u0433\u043e \u0447\u0435\u0440\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c *\/ static void _image_reset(void) {     for (int y = 0; y &lt; IMAGE_HEIGHT; y++)         for (int x = 0; x &lt; IMAGE_WIDTH; x++)             pixdata[y][x] = 0; }  \/*! \\brief \u041e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u0445\u043e\u043b\u0441\u0442\u0435 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430  * \\param[in] y Y \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430 *\/ static void _texture_draw(int t, int x, int y) {     for (int ty = 0; ty &lt; TEXTURE_HEIGHT; ty++)         for (int tx = 0; tx &lt; TEXTURE_WIDTH; tx++)             if (textures[t][ty][tx])                 pixdata[ty +                          y * (TEXTURE_TOP_HEIGHT \/ 2) +                          x * (TEXTURE_TOP_HEIGHT \/ 2)]                        [tx +                          IMAGE_SHIFTX +                          x * (TEXTURE_TOP_WIDTH \/ 2) -                          y * TEXTURE_TOP_HEIGHT] = textures[t][ty][tx]; }  \/*! \\brief \u0427\u0438\u0442\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430 \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043a\u0430\u0440\u0442\u0443   * \\param[in] filename \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430 *\/ static void _map_read(const char * filename) {     int f = open(filename, 0);     read(f, mapdata, MAP_FILEDATA);     close(f); }  \/*! \\brief \u0417\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0432\u0445\u043e\u0434\u044b \u0438\u0437 \u0444\u0430\u0439\u043b\u0430-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0432\u0445\u043e\u0434  * \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0430 \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0440\u043e\u043d\u0442\u0430 \u0432\u043e\u043b\u043d\u044b *\/ static void _map_wire_inputs(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)         for (int x = 0; x &lt; MAP_WIDTH; x++)             if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                 mapdata[y][x] = MAPCHAR_WIRE; }  \/*! \\brief \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0437\u0430\u043b\u0438\u0432\u043a\u0443 \u043f\u0440\u043e\u0432\u043e\u0434\u043d\u0438\u043a\u0430 \u043d\u0443\u0436\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c  * \\param[in] t \u0418\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442 \u0430\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430   * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0437\u0430\u043b\u0438\u0432\u043a\u0438  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0437\u0430\u043b\u0438\u0432\u043a\u0438  * \\param[in] c \u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435  * \\param[in] l \u0426\u0435\u043b\u0435\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 *\/ static void _map_fill(int t, int x, int y, int c, int l) {     if ((x &gt;= MAP_WIDTH || y &gt;= MAP_HEIGHT ||           x &lt; 0 || y &lt; 0) || (mapdata[y][x] == l)         || (mapdata[y][x] != c))         return;     mapdata[y][x] = l;     _map_fill(t, x - 1, y, c, l);     _map_fill(t, x + 1, y, c, l);     _map_fill(t, x, y - 1, c, l);     _map_fill(t, x, y + 1, c, l); }  \/*! \\brief \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432\u0445\u043e\u0434\u044b \u0441\u0445\u0435\u043c\u044b \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f  * \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430.  * \\param[in] counter \u0421\u0447\u0435\u0442\u0447\u0438\u043a *\/ static void _map_wire_counter(int counter) {     _map_fill(0, 2, 3,  mapdata[3][2],  counter &amp; 1 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 7,  mapdata[7][2],  counter &amp; 2 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 11, mapdata[11][2], counter &amp; 4 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 15, mapdata[15][2], counter &amp; 8 ? MAPCHAR_PLUS : MAPCHAR_MINUS); }  \/*! \\brief \u041f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u0440\u0430\u0441\u0447\u0435\u0442 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e (\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e) \u0442\u043e\u043a\u0430 \u043f\u043e\u0441\u043b\u0435 NOR-\u0443\u0437\u043b\u0430 *\/ static void _map_process_gates(void) {            for (int i = 0; i &lt; MAP_ITERATIONS; i++)         for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if (mapdata[y][x] == MAPCHAR_NOR)                     _map_fill(0, x + 1, y, mapdata[y][x + 1],                         !(mapdata[y - 1][x] == MAPCHAR_PLUS ? 1 : 0                        || mapdata[y + 1][x] == MAPCHAR_PLUS ? 1 : 0) ?                              MAPCHAR_PLUS : MAPCHAR_MINUS); }  \/* \u041a\u043e\u0434 \u0434\u043e \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  int _x[] = { 15117427, 8413248, 5878632, 13027014, 1 }; int rn = 2166136261;  void *T;  void e(int t, int x, int y, int c, int l) {     if ((x &gt;= TEXTURE_WIDTH || y &gt;= TEXTURE_HEIGHT ||           x &lt; 0 || y &lt; 0) ||           (textures[t][y][x] == l) ||           (textures[t][y][x] != c))         return;     textures[t][y][x] = l;     e(t, x - 1, y, c, l);     e(t, x + 1, y, c, l);     e(t, x, y - 1, c, l);     e(t, x, y + 1, c, l); }  void k(int t, int x, int y, int c, int l) {     while (c--) {         textures[t][y][x++] = l;         textures[t][y++][x++] = l;     } }  void r(int t, int x, int y, int c, int l) {     while (c--) {         textures[t][y][x--] = l;         textures[t][y++][x--] = l;     } }  void u(int t, int x, int y, int c, int l) {     while (c--)         textures[t][y++][x] = l; }  char *z[8] = {      (char[]) {4},      (char[]) {6, 1 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16, 0, 0,               21 + 0 * 3 - 0, 16, 1, 63, 21 + 0 * 3 - 0, 16, 2,               63 * 0, 21 - 0, 4, 2, 31 + 0, 36 - 0, 4, 0 + 1,               32 - 1, 5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1, 63,               21 + 1 * 3 - 0, 16, 2, 63 * 1, 21 - 0, 4, 2, 31 + 1,               36 - 0, 4, 6, 1 * 4 + 0, 3, 31, 8 - 0, 6, 1 * 4 + 2,               3, 33, 38 - 0, 6, 1 * 4 + 3, 3, 30, 38 - 0, 4},     (char[]) {5, 1},      (char[]) {6, 0 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16,               0, 0, 21 + 0 * 3 - 0, 16, 1, 63,               21 + 0 * 3 - 0, 16, 2, 63 * 0, 21 - 0,               4, 2, 31 + 0, 36 - 0, 4, 0 + 1, 32 - 1,               5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1,               63, 21 + 1 * 3 - 0, 16, 2, 63 * 1,               21 - 0, 4, 2, 31 + 1, 36 - 0, 4, 6,               0 * 4 + 0, 3, 31, 8 - 0, 6, 0 * 4 + 2,               3, 33, 38 - 0, 6, 0 * 4 + 3, 3, 30,               38 - 0,               4},     (char[]) {4},      (char[]) {4},     (char[]) {6, 2 * 4 + 1, 0 + 0, 32 - 0, 5 - 3, 16, 0, 0,               21 + 0 * 3 - 3, 16, 1, 63, 21 + 0 * 3 - 3, 16, 2, 63 * 0,               21 - 3, 4, 2, 31 + 0, 36 - 3, 4, 0 + 1, 32 - 1, 5 - 3,               16, 0, 0, 21 + 1 * 3 - 3, 16, 1, 63, 21 + 1 * 3 - 3, 16,               2, 63 * 1, 21 - 3, 4, 2, 31 + 1, 36 - 3, 4, 6, 2 * 4 + 0,               3, 31, 8 - 3, 6, 2 * 4 + 2, 3, 33, 38 - 3, 6, 2 * 4 + 3,               3, 30, 38 - 3, 4},      (char[]) {6, 13, 0, 32, 9 + 0, 12 - 0,               0, 8 + 0 + 0, 21, 12 - 0, 1,               31, 9 + 0, 12 - 0, 1,               55 - 0 - 0, 21, 12 - 0, 0,               32, 9 + 3, 12 - 3, 0,               8 + 3 + 3, 21, 12 - 3, 1,               31, 9 + 3, 12 - 3, 1,               55 - 3 - 3, 21, 12 - 3, 6,               14 + 0, 2, 31 + 0, 13, 4,               1 - 0, 31 + 0, 16, 7, 3,               30 + 3 * 0, 14, 6,               12 + 0 * 4, 3, 32 - 0,               11 + 0 * 8, 6, 14 + 1, 2,               31 + 1, 13, 4, 1 - 1,               31 + 1, 16, 7, 3,               30 + 3 * 1, 14, 6,               12 + 1 * 4, 3, 32 - 1,               11 + 1 * 8,               4} };  int main(int a, char *s[]) {     display = XOpenDisplay(0);     window = XCreateSimpleWindow(display,                                   RootWindow(display, DefaultScreen(display)),                                   0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, 1, 0, 0);     image = XCreateImage(display,                       DefaultVisual(display, DefaultScreen(display)),                       DefaultDepth(display, DefaultScreen(display)),                      2, 0, (char *) pixdata, IMAGE_WIDTH, IMAGE_HEIGHT, 32, 0);     for (int i = 0; i &lt; 8; i++) {         char *p = z[i];         int c = 0;         while (*p != 4) {             switch (*p) {             case 0:                 k(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 1:                 r(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 2:                 u(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 3:                 e(i, p[1]                   , p[2], 0, c);                 p += 3;                 break;             case 5:                 p = z[p[1]];                 break;             case 6:                 c = _x[p[1] \/ 4] - 1643277 * (p[1] % 4);                 p += 2;                 break;             }         }     }     while (a++) {         _map_read(s[1]);         _map_wire_inputs();         _map_wire_counter(a);         _map_process_gates();                  _image_reset();                    for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 _texture_draw(((mapdata[y][x] &gt;&gt; 4) &amp; 1) &lt;&lt; 2 | (mapdata[y][x] &amp; 3), x, y);                          for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                     _texture_draw(7, x, y);         for (int y = 0; y &lt; IMAGE_HEIGHT; y++)             for (int x = 0; x &lt; IMAGE_WIDTH; x++) {                 pixdata[y][x] &amp;= 14737632 | (31 &lt;&lt; ((x % 3) &lt;&lt; 3));                 pixdata[y][x] += 986895 &amp; (rn *= 16777619);             }         XPutImage(display, window,                    DefaultGC(display, DefaultScreen(display)),                    image, 0, 0, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);         XMapWindow(display, window);         XFlush(display);                  sleep(1);     }      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<h4>\u0421\u0442\u0440\u0430\u043d\u043d\u044b\u0439 \u0431\u043b\u043e\u043a<\/h4>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435  <\/p>\n<pre><code class=\"cpp\">_texture_draw(((mapdata[y][x] &gt;&gt; 4) &amp; 1) &lt;&lt; 2 | (mapdata[y][x] &amp; 3), x, y);<\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u043f\u043e\u043b\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 mapdata \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430:  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<th>enum<\/th>\n<th>int<\/th>\n<th>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/th>\n<\/tr>\n<tr>\n<td>MAPCHAR_WIRE<\/td>\n<td>46<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>MAPCHAR_PLUS<\/td>\n<td>43<\/td>\n<td>3<\/td>\n<\/tr>\n<tr>\n<td>MAPCHAR_MINUS<\/td>\n<td>45<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>MAPCHAR_NOR<\/td>\n<td>62<\/td>\n<td>6<\/td>\n<\/tr>\n<tr>\n<td>MAPCHAR_EMPTY<\/td>\n<td>32<\/td>\n<td>0<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u0410\u0433\u0430, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u043e \u0438\u0442\u043e\u0433\u0430\u043c \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440.  <\/p>\n<blockquote><p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0437 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0433\u043e \u0438 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u0430\u0441\u044c \u043f\u0430\u0440\u0430 \u0447\u0430\u0441\u043e\u0432. \u042f \u0432\u044b\u043f\u0438\u0441\u0430\u043b \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u043b\u0438 \u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0440\u043e\u0432\u043e\u0434\u0430 \u0438 NOR-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0430 \u043f\u043e\u0442\u043e\u043c \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u0432 \u0438\u0445 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0431\u0432\u043e\u0434\u0438\u043b \u043a\u0440\u0443\u0436\u043e\u0447\u043a\u0430\u043c\u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u0438. \u041a\u0440\u043e\u043c\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0431\u044b\u043b \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u043c\u0438, \u043d\u043e \u043e\u043d \u0434\u043b\u0438\u043d\u043d\u0435\u0435, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435 \u043f\u043e\u0434\u043e\u0448\u0435\u043b \u043f\u043e \u043b\u0438\u043c\u0438\u0442\u0443 \u0442\u043e\u043a\u0435\u043d\u043e\u0432.<\/p><\/blockquote>\n<p>  \u0417\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u044d\u0442\u043e \u0434\u0430\u0435\u0442 \u043d\u0430\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0447\u043b\u0435\u043d\u0438\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c enum \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b:  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u0441\u043b\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;X11\/Xlib.h&gt; #include &lt;sys\/types.h&gt; #include &lt;sys\/stat.h&gt; #include &lt;fcntl.h&gt; #include &lt;unistd.h&gt;  \/* \u041a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_WIDTH (1220) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_HEIGHT (616) \/*! \\brief \u0421\u0434\u0432\u0438\u0433 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0433\u0440\u0430\u043d\u0438 \u043a\u0430\u0440\u0442\u044b \u043e\u0442 \u043b\u0435\u0432\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b *\/ #define IMAGE_SHIFTX (580)  \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u043a\u0441\u0442\u0443\u0440 *\/ #define TEXTURE_COUNT (8) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_HEIGHT (40) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0433\u0440\u0430\u043d\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_TOP_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0433\u0440\u0430\u043d\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_TOP_HEIGHT (32)  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f *\/ #define MAP_WIDTH (19) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f *\/ #define MAP_HEIGHT (19) \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435-\u0447\u0435\u0440\u0442\u0435\u0436\u0435. \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '\\n' *\/ #define MAP_FILEDATA ((MAP_WIDTH + 1) * MAP_HEIGHT) \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 NOR-\u0443\u0437\u043b\u043e\u0432 *\/ #define MAP_ITERATIONS (20)  \/*! \\brief \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0444\u0430\u0439\u043b\u0430-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 *\/ enum map_characters {     MAPCHAR_WIRE  = '.', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434            (ASCII = 46) *\/     MAPCHAR_PLUS  = '+', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434 (\u0435\u0441\u0442\u044c \u0442\u043e\u043a) (ASCII = 43) *\/     MAPCHAR_MINUS = '-', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434 (\u043d\u0435\u0442 \u0442\u043e\u043a\u0430) (ASCII = 45) *\/     MAPCHAR_NOR   = '&gt;', \/**&lt; NOR-\u044d\u043b\u0435\u043c\u0435\u043d\u0442       (ASCII = 62) *\/     MAPCHAR_EMPTY = ' ', \/**&lt; \u041f\u0443\u0441\u0442\u043e\u0439 \u0431\u043b\u043e\u043a       (ASCII = 32) *\/ };  \/*! \\brief \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440 *\/ enum textures_indexes {     TEXINDEX_EMPTY = (0), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u043f\u0443\u0441\u0442\u043e\u0439 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b                 *\/     TEXINDEX_MINUS = (1), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b &quot;\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0430&quot; *\/     TEXINDEX_WIRE  = (2), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0430   *\/     TEXINDEX_PLUS  = (3), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b &quot;\u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0433\u043e&quot; \u043f\u0440\u043e\u0432\u043e\u0434\u0430  *\/     \/**\/     TEXINDEX_NOR   = (6)  \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b NOR-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430           *\/ };  \/*! \\brief \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b *\/ enum program_arguments {      ARG_PROGRAM,  \/**&lt; \u0418\u043c\u044f \u0441\u0430\u043c\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b *\/     ARG_BLUEPRINT \/**&lt; \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430   *\/ };  \/*! \\brief \u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.  * \u0422\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043a int \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 *\/ int pixdata[IMAGE_HEIGHT][IMAGE_WIDTH]; \/*! \\brief \u0422\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0431\u043b\u043e\u043a\u043e\u0432, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u044b\u0445 \u043d\u0430 \u043f\u043e\u043b\u0435 *\/ int textures[TEXTURE_COUNT][TEXTURE_HEIGHT][TEXTURE_WIDTH] = { 0 }; \/*! \\brief \u0414\u0430\u043d\u043d\u044b\u0435 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f.   * \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '\\n' *\/ char mapdata[MAP_HEIGHT][MAP_WIDTH + 1];  \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0438\u0441\u043f\u043b\u0435\u044f Xlib *\/ Display * display; \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430 Xlib *\/ Window window; \/*! \\brief \u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d *\/ XImage * image;  \/* \\brief \u041e\u0431\u043d\u0443\u043b\u044f\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044f \u0435\u0433\u043e \u0447\u0435\u0440\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c *\/ static void _image_reset(void) {     for (int y = 0; y &lt; IMAGE_HEIGHT; y++)         for (int x = 0; x &lt; IMAGE_WIDTH; x++)             pixdata[y][x] = 0; }  \/*! \\brief \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u0438\u043c\u0432\u043e\u043b \u0438\u0437 \u0447\u0435\u0440\u0442\u0435\u0436\u0430 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] elem \u0421\u0438\u043c\u0432\u043e\u043b \u0447\u0435\u0440\u0442\u0435\u0436\u0430  * \\return \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b *\/ static int _map2texture(char elem) {     return ((elem &gt;&gt; 4) &amp; 1) &lt;&lt; 2 | (elem &amp; 3); }  \/*! \\brief \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u0437 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0430\u0439\u043b\u043e\u0432 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043a\u0430\u0440\u0442\u0435 *\/ static void _image_compile(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)         for (int x = 0; x &lt; MAP_WIDTH; x++)             _texture_draw(_map2texture(mapdata[y][x]), x, y); }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 *\/ static void _image_draw(void) {     XPutImage(display, window,                DefaultGC(display, DefaultScreen(display)),                image, 0, 0, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);     XMapWindow(display, window);     XFlush(display); }  \/*! \\brief \u041e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u0445\u043e\u043b\u0441\u0442\u0435 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430  * \\param[in] y Y \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430 *\/ static void _texture_draw(int t, int x, int y) {     for (int ty = 0; ty &lt; TEXTURE_HEIGHT; ty++)         for (int tx = 0; tx &lt; TEXTURE_WIDTH; tx++)             if (textures[t][ty][tx])                 pixdata[ty +                          y * (TEXTURE_TOP_HEIGHT \/ 2) +                          x * (TEXTURE_TOP_HEIGHT \/ 2)]                        [tx +                          IMAGE_SHIFTX +                          x * (TEXTURE_TOP_WIDTH \/ 2) -                          y * TEXTURE_TOP_HEIGHT] = textures[t][ty][tx]; }  \/*! \\brief \u0427\u0438\u0442\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430 \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043a\u0430\u0440\u0442\u0443   * \\param[in] filename \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430 *\/ static void _map_read(const char * filename) {     int f = open(filename, 0);     read(f, mapdata, MAP_FILEDATA);     close(f); }  \/*! \\brief \u0417\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0432\u0445\u043e\u0434\u044b \u0438\u0437 \u0444\u0430\u0439\u043b\u0430-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0432\u0445\u043e\u0434  * \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0430 \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0440\u043e\u043d\u0442\u0430 \u0432\u043e\u043b\u043d\u044b *\/ static void _map_wire_inputs(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)         for (int x = 0; x &lt; MAP_WIDTH; x++)             if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                 mapdata[y][x] = MAPCHAR_WIRE; }  \/*! \\brief \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0437\u0430\u043b\u0438\u0432\u043a\u0443 \u043f\u0440\u043e\u0432\u043e\u0434\u043d\u0438\u043a\u0430 \u043d\u0443\u0436\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c  * \\param[in] t \u0418\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442 \u0430\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430   * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0437\u0430\u043b\u0438\u0432\u043a\u0438  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0437\u0430\u043b\u0438\u0432\u043a\u0438  * \\param[in] c \u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435  * \\param[in] l \u0426\u0435\u043b\u0435\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 *\/ static void _map_fill(int t, int x, int y, int c, int l) {     if ((x &gt;= MAP_WIDTH || y &gt;= MAP_HEIGHT ||           x &lt; 0 || y &lt; 0) || (mapdata[y][x] == l)         || (mapdata[y][x] != c))         return;     mapdata[y][x] = l;     _map_fill(t, x - 1, y, c, l);     _map_fill(t, x + 1, y, c, l);     _map_fill(t, x, y - 1, c, l);     _map_fill(t, x, y + 1, c, l); }  \/*! \\brief \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432\u0445\u043e\u0434\u044b \u0441\u0445\u0435\u043c\u044b \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f  * \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430.  * \\param[in] counter \u0421\u0447\u0435\u0442\u0447\u0438\u043a *\/ static void _map_wire_counter(int counter) {     _map_fill(0, 2, 3,  mapdata[3][2],  counter &amp; 1 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 7,  mapdata[7][2],  counter &amp; 2 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 11, mapdata[11][2], counter &amp; 4 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 15, mapdata[15][2], counter &amp; 8 ? MAPCHAR_PLUS : MAPCHAR_MINUS); }  \/*! \\brief \u041f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u0440\u0430\u0441\u0447\u0435\u0442 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e (\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e) \u0442\u043e\u043a\u0430 \u043f\u043e\u0441\u043b\u0435 NOR-\u0443\u0437\u043b\u0430 *\/ static void _map_process_gates(void) {            for (int i = 0; i &lt; MAP_ITERATIONS; i++)         for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if (mapdata[y][x] == MAPCHAR_NOR)                     _map_fill(0, x + 1, y, mapdata[y][x + 1],                         !(mapdata[y - 1][x] == MAPCHAR_PLUS ? 1 : 0                        || mapdata[y + 1][x] == MAPCHAR_PLUS ? 1 : 0) ?                              MAPCHAR_PLUS : MAPCHAR_MINUS); }  \/* \u041a\u043e\u0434 \u0434\u043e \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  int _x[] = { 15117427, 8413248, 5878632, 13027014, 1 }; int rn = 2166136261;  void *T;  void e(int t, int x, int y, int c, int l) {     if ((x &gt;= TEXTURE_WIDTH || y &gt;= TEXTURE_HEIGHT ||           x &lt; 0 || y &lt; 0) ||           (textures[t][y][x] == l) ||           (textures[t][y][x] != c))         return;     textures[t][y][x] = l;     e(t, x - 1, y, c, l);     e(t, x + 1, y, c, l);     e(t, x, y - 1, c, l);     e(t, x, y + 1, c, l); }  void k(int t, int x, int y, int c, int l) {     while (c--) {         textures[t][y][x++] = l;         textures[t][y++][x++] = l;     } }  void r(int t, int x, int y, int c, int l) {     while (c--) {         textures[t][y][x--] = l;         textures[t][y++][x--] = l;     } }  void u(int t, int x, int y, int c, int l) {     while (c--)         textures[t][y++][x] = l; }  char *z[8] = {      (char[]) {4},      (char[]) {6, 1 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16, 0, 0,               21 + 0 * 3 - 0, 16, 1, 63, 21 + 0 * 3 - 0, 16, 2,               63 * 0, 21 - 0, 4, 2, 31 + 0, 36 - 0, 4, 0 + 1,               32 - 1, 5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1, 63,               21 + 1 * 3 - 0, 16, 2, 63 * 1, 21 - 0, 4, 2, 31 + 1,               36 - 0, 4, 6, 1 * 4 + 0, 3, 31, 8 - 0, 6, 1 * 4 + 2,               3, 33, 38 - 0, 6, 1 * 4 + 3, 3, 30, 38 - 0, 4},     (char[]) {5, 1},      (char[]) {6, 0 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16,               0, 0, 21 + 0 * 3 - 0, 16, 1, 63,               21 + 0 * 3 - 0, 16, 2, 63 * 0, 21 - 0,               4, 2, 31 + 0, 36 - 0, 4, 0 + 1, 32 - 1,               5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1,               63, 21 + 1 * 3 - 0, 16, 2, 63 * 1,               21 - 0, 4, 2, 31 + 1, 36 - 0, 4, 6,               0 * 4 + 0, 3, 31, 8 - 0, 6, 0 * 4 + 2,               3, 33, 38 - 0, 6, 0 * 4 + 3, 3, 30,               38 - 0,               4},     (char[]) {4},      (char[]) {4},     (char[]) {6, 2 * 4 + 1, 0 + 0, 32 - 0, 5 - 3, 16, 0, 0,               21 + 0 * 3 - 3, 16, 1, 63, 21 + 0 * 3 - 3, 16, 2, 63 * 0,               21 - 3, 4, 2, 31 + 0, 36 - 3, 4, 0 + 1, 32 - 1, 5 - 3,               16, 0, 0, 21 + 1 * 3 - 3, 16, 1, 63, 21 + 1 * 3 - 3, 16,               2, 63 * 1, 21 - 3, 4, 2, 31 + 1, 36 - 3, 4, 6, 2 * 4 + 0,               3, 31, 8 - 3, 6, 2 * 4 + 2, 3, 33, 38 - 3, 6, 2 * 4 + 3,               3, 30, 38 - 3, 4},      (char[]) {6, 13, 0, 32, 9 + 0, 12 - 0,               0, 8 + 0 + 0, 21, 12 - 0, 1,               31, 9 + 0, 12 - 0, 1,               55 - 0 - 0, 21, 12 - 0, 0,               32, 9 + 3, 12 - 3, 0,               8 + 3 + 3, 21, 12 - 3, 1,               31, 9 + 3, 12 - 3, 1,               55 - 3 - 3, 21, 12 - 3, 6,               14 + 0, 2, 31 + 0, 13, 4,               1 - 0, 31 + 0, 16, 7, 3,               30 + 3 * 0, 14, 6,               12 + 0 * 4, 3, 32 - 0,               11 + 0 * 8, 6, 14 + 1, 2,               31 + 1, 13, 4, 1 - 1,               31 + 1, 16, 7, 3,               30 + 3 * 1, 14, 6,               12 + 1 * 4, 3, 32 - 1,               11 + 1 * 8,               4} };  int main(int argc, char * args[]) {     display = XOpenDisplay(0);     window = XCreateSimpleWindow(display,                                   RootWindow(display, DefaultScreen(display)),                                   0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, 1, 0, 0);     image = XCreateImage(display,                       DefaultVisual(display, DefaultScreen(display)),                       DefaultDepth(display, DefaultScreen(display)),                      2, 0, (char *) pixdata, IMAGE_WIDTH, IMAGE_HEIGHT, 32, 0);     for (int i = 0; i &lt; 8; i++) {         char *p = z[i];         int c = 0;         while (*p != 4) {             switch (*p) {             case 0:                 k(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 1:                 r(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 2:                 u(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 3:                 e(i, p[1]                   , p[2], 0, c);                 p += 3;                 break;             case 5:                 p = z[p[1]];                 break;             case 6:                 c = _x[p[1] \/ 4] - 1643277 * (p[1] % 4);                 p += 2;                 break;             }         }     }     unsigned int counter = 0;     while (counter++) {         _map_read(args[ARG_BLUEPRINT]);         _map_wire_inputs();         _map_wire_counter(counter);         _map_process_gates();                  _image_reset();                   _image_compile();                                            for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                     _texture_draw(7, x, y);         for (int y = 0; y &lt; IMAGE_HEIGHT; y++)             for (int x = 0; x &lt; IMAGE_WIDTH; x++) {                 pixdata[y][x] &amp;= 14737632 | (31 &lt;&lt; ((x % 3) &lt;&lt; 3));                 pixdata[y][x] += 986895 &amp; (rn *= 16777619);             }                  _image_draw();                  sleep(1);     }      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<h4>\u0422\u0435\u043a\u0441\u0442\u0443\u0440\u0430 #7<\/h4>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c\u0441\u044f \u043a \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u00abz\u00bb, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 8 \u0431\u043b\u043e\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u0430\u043a \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440. \u0418 \u0432 \u043d\u0435\u043c \u0434\u0430\u0436\u0435 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043f\u0440\u043e\u0431\u0435\u043b\u0430 \u043d\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u044f\u0445 4 \u0438 5, \u043f\u0440\u044f\u043c\u043e \u043a\u0430\u043a \u0432 \u043d\u0430\u0448\u0435\u043c enum, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440. \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 8 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0430 \u043c\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u00ab\u043e\u0442\u043a\u0440\u044b\u0442\u044c\u00bb \u0442\u043e\u043b\u044c\u043a\u043e 7. \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438, \u0442\u043e \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0443\u0447\u0430\u0441\u0442\u043e\u043a \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0438\u0441\u0443\u0435\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e 7\u044e \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443:  <\/p>\n<pre><code class=\"cpp\">        for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                     _texture_draw(7, x, y);<\/code><\/pre>\n<p>  \u041f\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e, \u043d\u043e \u0437\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c \u044d\u0442\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<br \/>  \u0414\u043e:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/cg\/da\/ww\/cgdawwcro4camniddcrqnnoxwzc.png\"><br \/>  \u041f\u043e\u0441\u043b\u0435:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ve\/vh\/bm\/vevhbmkzz27vvwsgkqx76mflvyo.png\"><br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u043e\u0442\u0432\u0435\u0440\u0441\u0442\u0438\u044f \u043d\u0430 \u043f\u043b\u0430\u0442\u0435 \u0438 \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0435 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a enum, \u0432\u044b\u043d\u0435\u0441\u044f \u0435\u0451 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0443 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0412\u0441\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u0441\u0431\u043e\u0440\u0435:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;X11\/Xlib.h&gt; #include &lt;sys\/types.h&gt; #include &lt;sys\/stat.h&gt; #include &lt;fcntl.h&gt; #include &lt;unistd.h&gt;  \/* \u041a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_WIDTH (1220) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_HEIGHT (616) \/*! \\brief \u0421\u0434\u0432\u0438\u0433 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0433\u0440\u0430\u043d\u0438 \u043a\u0430\u0440\u0442\u044b \u043e\u0442 \u043b\u0435\u0432\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b *\/ #define IMAGE_SHIFTX (580)  \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u043a\u0441\u0442\u0443\u0440 *\/ #define TEXTURE_COUNT (8) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_HEIGHT (40) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0433\u0440\u0430\u043d\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_TOP_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0433\u0440\u0430\u043d\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_TOP_HEIGHT (32)  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f *\/ #define MAP_WIDTH (19) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f *\/ #define MAP_HEIGHT (19) \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435-\u0447\u0435\u0440\u0442\u0435\u0436\u0435. \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '\\n' *\/ #define MAP_FILEDATA ((MAP_WIDTH + 1) * MAP_HEIGHT) \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 NOR-\u0443\u0437\u043b\u043e\u0432 *\/ #define MAP_ITERATIONS (20)  \/*! \\brief \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0444\u0430\u0439\u043b\u0430-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 *\/ enum map_characters {     MAPCHAR_WIRE  = '.', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434            (ASCII = 46) *\/     MAPCHAR_PLUS  = '+', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434 (\u0435\u0441\u0442\u044c \u0442\u043e\u043a) (ASCII = 43) *\/     MAPCHAR_MINUS = '-', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434 (\u043d\u0435\u0442 \u0442\u043e\u043a\u0430) (ASCII = 45) *\/     MAPCHAR_NOR   = '&gt;', \/**&lt; NOR-\u044d\u043b\u0435\u043c\u0435\u043d\u0442       (ASCII = 62) *\/     MAPCHAR_EMPTY = ' ', \/**&lt; \u041f\u0443\u0441\u0442\u043e\u0439 \u0431\u043b\u043e\u043a       (ASCII = 32) *\/ };  \/*! \\brief \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440 *\/ enum textures_indexes {     TEXINDEX_EMPTY = (0), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u043f\u0443\u0441\u0442\u043e\u0439 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b                 *\/     TEXINDEX_MINUS = (1), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b &quot;\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0430&quot; *\/     TEXINDEX_WIRE  = (2), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0430   *\/     TEXINDEX_PLUS  = (3), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b &quot;\u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0433\u043e&quot; \u043f\u0440\u043e\u0432\u043e\u0434\u0430  *\/     \/**\/     TEXINDEX_NOR   = (6), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b NOR-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430           *\/     TEXINDEX_HOLE  = (7)  \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043e\u0442\u0432\u0435\u0440\u0441\u0442\u0438\u044f \u043d\u0430 \u043f\u043b\u0430\u0442\u0435     *\/ };  \/*! \\brief \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b *\/ enum program_arguments {      ARG_PROGRAM,  \/**&lt; \u0418\u043c\u044f \u0441\u0430\u043c\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b *\/     ARG_BLUEPRINT \/**&lt; \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430   *\/ };  \/*! \\brief \u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.  * \u0422\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043a int \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 *\/ int pixdata[IMAGE_HEIGHT][IMAGE_WIDTH]; \/*! \\brief \u0422\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0431\u043b\u043e\u043a\u043e\u0432, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u044b\u0445 \u043d\u0430 \u043f\u043e\u043b\u0435 *\/ int textures[TEXTURE_COUNT][TEXTURE_HEIGHT][TEXTURE_WIDTH] = { 0 }; \/*! \\brief \u0414\u0430\u043d\u043d\u044b\u0435 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f.   * \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '\\n' *\/ char mapdata[MAP_HEIGHT][MAP_WIDTH + 1];  \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0438\u0441\u043f\u043b\u0435\u044f Xlib *\/ Display * display; \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430 Xlib *\/ Window window; \/*! \\brief \u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d *\/ XImage * image;  static void _texture_draw(int t, int x, int y);  \/*! \\brief \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438 \u0441\u043e\u043f\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 *\/ static void _image_create(void) {     display = XOpenDisplay(0);     window = XCreateSimpleWindow(display,                                   RootWindow(display, DefaultScreen(display)),                                   0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, 1, 0, 0);     image = XCreateImage(display,                       DefaultVisual(display, DefaultScreen(display)),                       DefaultDepth(display, DefaultScreen(display)),                      2, 0, (char *) pixdata, IMAGE_WIDTH, IMAGE_HEIGHT, 32, 0); }  \/* \\brief \u041e\u0431\u043d\u0443\u043b\u044f\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044f \u0435\u0433\u043e \u0447\u0435\u0440\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c *\/ static void _image_reset(void) {     for (int y = 0; y &lt; IMAGE_HEIGHT; y++)         for (int x = 0; x &lt; IMAGE_WIDTH; x++)             pixdata[y][x] = 0; }  \/*! \\brief \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u0438\u043c\u0432\u043e\u043b \u0438\u0437 \u0447\u0435\u0440\u0442\u0435\u0436\u0430 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] elem \u0421\u0438\u043c\u0432\u043e\u043b \u0447\u0435\u0440\u0442\u0435\u0436\u0430  * \\return \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b *\/ static int _map2texture(char elem) {     return ((elem &gt;&gt; 4) &amp; 1) &lt;&lt; 2 | (elem &amp; 3); }  \/*! \\brief \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u0437 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0430\u0439\u043b\u043e\u0432 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043a\u0430\u0440\u0442\u0435 *\/ static void _image_compile(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)         for (int x = 0; x &lt; MAP_WIDTH; x++)             _texture_draw(_map2texture(mapdata[y][x]), x, y); }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 *\/ static void _image_draw(void) {     XPutImage(display, window,                DefaultGC(display, DefaultScreen(display)),                image, 0, 0, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);     XMapWindow(display, window);     XFlush(display); }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u043e\u0442\u0432\u0435\u0440\u0441\u0442\u0438\u044f \u043d\u0430 \u043f\u0435\u0447\u0430\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0435 *\/ static void _image_drill(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                     _texture_draw(TEXINDEX_HOLE, x, y); }  \/*! \\brief \u041e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u0445\u043e\u043b\u0441\u0442\u0435 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430  * \\param[in] y Y \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430 *\/ static void _texture_draw(int t, int x, int y) {     for (int ty = 0; ty &lt; TEXTURE_HEIGHT; ty++)         for (int tx = 0; tx &lt; TEXTURE_WIDTH; tx++)             if (textures[t][ty][tx])                 pixdata[ty +                          y * (TEXTURE_TOP_HEIGHT \/ 2) +                          x * (TEXTURE_TOP_HEIGHT \/ 2)]                        [tx +                          IMAGE_SHIFTX +                          x * (TEXTURE_TOP_WIDTH \/ 2) -                          y * TEXTURE_TOP_HEIGHT] = textures[t][ty][tx]; }  \/*! \\brief \u0427\u0438\u0442\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430 \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043a\u0430\u0440\u0442\u0443   * \\param[in] filename \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430 *\/ static void _map_read(const char * filename) {     int f = open(filename, 0);     read(f, mapdata, MAP_FILEDATA);     close(f); }  \/*! \\brief \u0417\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0432\u0445\u043e\u0434\u044b \u0438\u0437 \u0444\u0430\u0439\u043b\u0430-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0432\u0445\u043e\u0434  * \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0430 \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0440\u043e\u043d\u0442\u0430 \u0432\u043e\u043b\u043d\u044b *\/ static void _map_wire_inputs(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)         for (int x = 0; x &lt; MAP_WIDTH; x++)             if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                 mapdata[y][x] = MAPCHAR_WIRE; }  \/*! \\brief \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0437\u0430\u043b\u0438\u0432\u043a\u0443 \u043f\u0440\u043e\u0432\u043e\u0434\u043d\u0438\u043a\u0430 \u043d\u0443\u0436\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c  * \\param[in] t \u0418\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442 \u0430\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430   * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0437\u0430\u043b\u0438\u0432\u043a\u0438  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0437\u0430\u043b\u0438\u0432\u043a\u0438  * \\param[in] c \u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435  * \\param[in] l \u0426\u0435\u043b\u0435\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 *\/ static void _map_fill(int t, int x, int y, int c, int l) {     if ((x &gt;= MAP_WIDTH || y &gt;= MAP_HEIGHT ||           x &lt; 0 || y &lt; 0) || (mapdata[y][x] == l)         || (mapdata[y][x] != c))         return;     mapdata[y][x] = l;     _map_fill(t, x - 1, y, c, l);     _map_fill(t, x + 1, y, c, l);     _map_fill(t, x, y - 1, c, l);     _map_fill(t, x, y + 1, c, l); }  \/*! \\brief \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432\u0445\u043e\u0434\u044b \u0441\u0445\u0435\u043c\u044b \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f  * \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430.  * \\param[in] counter \u0421\u0447\u0435\u0442\u0447\u0438\u043a *\/ static void _map_wire_counter(int counter) {     _map_fill(0, 2, 3,  mapdata[3][2],  counter &amp; 1 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 7,  mapdata[7][2],  counter &amp; 2 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 11, mapdata[11][2], counter &amp; 4 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 15, mapdata[15][2], counter &amp; 8 ? MAPCHAR_PLUS : MAPCHAR_MINUS); }  \/*! \\brief \u041f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u0440\u0430\u0441\u0447\u0435\u0442 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e (\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e) \u0442\u043e\u043a\u0430 \u043f\u043e\u0441\u043b\u0435 NOR-\u0443\u0437\u043b\u0430 *\/ static void _map_process_gates(void) {            for (int i = 0; i &lt; MAP_ITERATIONS; i++)         for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if (mapdata[y][x] == MAPCHAR_NOR)                     _map_fill(0, x + 1, y, mapdata[y][x + 1],                         !(mapdata[y - 1][x] == MAPCHAR_PLUS ? 1 : 0                        || mapdata[y + 1][x] == MAPCHAR_PLUS ? 1 : 0) ?                              MAPCHAR_PLUS : MAPCHAR_MINUS); }  \/* \u041a\u043e\u0434 \u0434\u043e \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  int _x[] = { 15117427, 8413248, 5878632, 13027014, 1 }; int rn = 2166136261;  void *T;  void e(int t, int x, int y, int c, int l) {     if ((x &gt;= TEXTURE_WIDTH || y &gt;= TEXTURE_HEIGHT ||           x &lt; 0 || y &lt; 0) ||           (textures[t][y][x] == l) ||           (textures[t][y][x] != c))         return;     textures[t][y][x] = l;     e(t, x - 1, y, c, l);     e(t, x + 1, y, c, l);     e(t, x, y - 1, c, l);     e(t, x, y + 1, c, l); }  void k(int t, int x, int y, int c, int l) {     while (c--) {         textures[t][y][x++] = l;         textures[t][y++][x++] = l;     } }  void r(int t, int x, int y, int c, int l) {     while (c--) {         textures[t][y][x--] = l;         textures[t][y++][x--] = l;     } }  void u(int t, int x, int y, int c, int l) {     while (c--)         textures[t][y++][x] = l; }  char *z[8] = {      (char[]) {4},      (char[]) {6, 1 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16, 0, 0,               21 + 0 * 3 - 0, 16, 1, 63, 21 + 0 * 3 - 0, 16, 2,               63 * 0, 21 - 0, 4, 2, 31 + 0, 36 - 0, 4, 0 + 1,               32 - 1, 5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1, 63,               21 + 1 * 3 - 0, 16, 2, 63 * 1, 21 - 0, 4, 2, 31 + 1,               36 - 0, 4, 6, 1 * 4 + 0, 3, 31, 8 - 0, 6, 1 * 4 + 2,               3, 33, 38 - 0, 6, 1 * 4 + 3, 3, 30, 38 - 0, 4},     (char[]) {5, 1},      (char[]) {6, 0 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16,               0, 0, 21 + 0 * 3 - 0, 16, 1, 63,               21 + 0 * 3 - 0, 16, 2, 63 * 0, 21 - 0,               4, 2, 31 + 0, 36 - 0, 4, 0 + 1, 32 - 1,               5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1,               63, 21 + 1 * 3 - 0, 16, 2, 63 * 1,               21 - 0, 4, 2, 31 + 1, 36 - 0, 4, 6,               0 * 4 + 0, 3, 31, 8 - 0, 6, 0 * 4 + 2,               3, 33, 38 - 0, 6, 0 * 4 + 3, 3, 30,               38 - 0,               4},     (char[]) {4},      (char[]) {4},     (char[]) {6, 2 * 4 + 1, 0 + 0, 32 - 0, 5 - 3, 16, 0, 0,               21 + 0 * 3 - 3, 16, 1, 63, 21 + 0 * 3 - 3, 16, 2, 63 * 0,               21 - 3, 4, 2, 31 + 0, 36 - 3, 4, 0 + 1, 32 - 1, 5 - 3,               16, 0, 0, 21 + 1 * 3 - 3, 16, 1, 63, 21 + 1 * 3 - 3, 16,               2, 63 * 1, 21 - 3, 4, 2, 31 + 1, 36 - 3, 4, 6, 2 * 4 + 0,               3, 31, 8 - 3, 6, 2 * 4 + 2, 3, 33, 38 - 3, 6, 2 * 4 + 3,               3, 30, 38 - 3, 4},      (char[]) {6, 13, 0, 32, 9 + 0, 12 - 0,               0, 8 + 0 + 0, 21, 12 - 0, 1,               31, 9 + 0, 12 - 0, 1,               55 - 0 - 0, 21, 12 - 0, 0,               32, 9 + 3, 12 - 3, 0,               8 + 3 + 3, 21, 12 - 3, 1,               31, 9 + 3, 12 - 3, 1,               55 - 3 - 3, 21, 12 - 3, 6,               14 + 0, 2, 31 + 0, 13, 4,               1 - 0, 31 + 0, 16, 7, 3,               30 + 3 * 0, 14, 6,               12 + 0 * 4, 3, 32 - 0,               11 + 0 * 8, 6, 14 + 1, 2,               31 + 1, 13, 4, 1 - 1,               31 + 1, 16, 7, 3,               30 + 3 * 1, 14, 6,               12 + 1 * 4, 3, 32 - 1,               11 + 1 * 8,               4} };  int main(int argc, char * args[]) {     _image_create();      for (int i = 0; i &lt; 8; i++) {         char *p = z[i];         int c = 0;         while (*p != 4) {             switch (*p) {             case 0:                 k(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 1:                 r(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 2:                 u(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 3:                 e(i, p[1]                   , p[2], 0, c);                 p += 3;                 break;             case 5:                 p = z[p[1]];                 break;             case 6:                 c = _x[p[1] \/ 4] - 1643277 * (p[1] % 4);                 p += 2;                 break;             }         }     }     unsigned int counter = 1;     while (counter++) {         _map_read(args[ARG_BLUEPRINT]);         _map_wire_inputs();         _map_wire_counter(counter);         _map_process_gates();                  _image_reset();                   _image_compile();         _image_drill();                  for (int y = 0; y &lt; IMAGE_HEIGHT; y++)             for (int x = 0; x &lt; IMAGE_WIDTH; x++) {                 pixdata[y][x] &amp;= 14737632 | (31 &lt;&lt; ((x % 3) &lt;&lt; 3));                 pixdata[y][x] += 986895 &amp; (rn *= 16777619);             }                  _image_draw();                  sleep(1);     }      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<h4>\u0428\u0435\u0439\u0434\u0435\u0440\u044b<\/h4>\n<p>  \u041a\u043e\u0442\u0438\u043a\u0438 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043e\u0431\u0435\u0449\u0430\u043b\u0438 \u0448\u0435\u0439\u0434\u0435\u0440\u044b. \u0418 \u043e\u043d\u0438 \u0442\u0443\u0442 \u0435\u0441\u0442\u044c. \u0410 \u0433\u0434\u0435 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443?  <\/p>\n<pre><code class=\"cpp\">         _image_reset();           \/\/ \u0420\u0430\u043d\u043e         _image_compile();       \/\/ \u0420\u0430\u043d\u043e         _image_drill();            \/\/ \u0420\u0430\u043d\u043e                  for (int y = 0; y &lt; IMAGE_HEIGHT; y++)             for (int x = 0; x &lt; IMAGE_WIDTH; x++) {                 pixdata[y][x] &amp;= 14737632 | (31 &lt;&lt; ((x % 3) &lt;&lt; 3));                 pixdata[y][x] += 986895 &amp; (rn *= 16777619);             }                  _image_draw();  \/\/ \u041f\u043e\u0437\u0434\u043d\u043e <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434\u043e\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e \u0437\u0430\u0448\u0443\u043c\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u044d\u043a\u0440\u0430\u043d\u0430 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442 LCD-\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0430 \u0434\u0430\u044e\u0442 \u044d\u0442\u0438 \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438. \u0410 \u043a\u0430\u043a \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442?<br \/>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439:  <\/p>\n<pre><code class=\"cpp\">pixdata[y][x] += 986895 &amp; (rn *= 16777619);<\/code><\/pre>\n<p>  \u041a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u0438\u043a\u0441\u0435\u043b\u044e \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 986895 (\u0447\u0442\u043e \u0432 hex-\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a 0x0f0f0f), \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0435\u0440\u0435\u0434 \u044d\u0442\u0438\u043c \u0431\u044b\u043b\u043e \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0431\u0438\u0442\u043e\u0432\u043e\u0435-\u0418 \u0441\u043e\u0432\u043c\u0435\u0449\u0435\u043d\u043e \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f rn \u043d\u0430 16777619. \u0415\u0441\u043b\u0438 \u0431\u044b rn \u0431\u044b\u043b\u043e \u0440\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b, \u0442\u043e \u044d\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043b\u043e \u0431\u044b \u0437\u0435\u0440\u043d\u0438\u0441\u0442\u044b\u0439 \u00ab\u0448\u0443\u043c\u00bb \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 16 \u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0439 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043a\u0430\u043d\u0430\u043b\u0443. \u0418 \u0440\u0430\u0437 \u0448\u0443\u043c \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u0437\u043d\u0430\u0447\u0438\u0442 rn \u0438 \u0435\u0441\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b. \u041d\u043e \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f?  <\/p>\n<pre><code class=\"cpp\">int rn = 2166136261;<\/code><\/pre>\n<p>  \u0412 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f rn \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e\u043c 2166136261. \u0410 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u0442\u0441\u044f \u043d\u0430 16777619. \u042d\u0442\u043e \u043d\u0438\u0447\u0442\u043e \u0438\u043d\u043e\u0435, \u043a\u0430\u043a \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u0441\u0435\u0432\u0434\u043e\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b. \u0412\u043e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <a href=\"https:\/\/en.wikipedia.org\/wiki\/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function\" rel=\"nofollow\">FNV<\/a> \u0431\u0435\u0437 \u0448\u0430\u0433\u0430 \u0441 XOR, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<p>  \u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430:  <\/p>\n<pre><code class=\"cpp\">pixdata[y][x] &amp;= 14737632 | (31 &lt;&lt; ((x % 3) &lt;&lt; 3));<\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0432\u0435\u0434\u0435\u043c \u0447\u0438\u0441\u043b\u043e 14737632 \u0432 \u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0438\u0440\u0438\u0447\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u043e\u0434\u043d\u043e\u0431\u0430\u0439\u0442\u043d\u044b\u043c\u0438 \u043a\u0430\u043d\u0430\u043b\u0430\u043c\u0438 \u0441\u0432\u0435\u0442\u0430: 0xe0e0e0. \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u043d\u044f\u0432 x \u0440\u0430\u0432\u043d\u044b\u043c \u043e\u0442 0 \u0434\u043e 3 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f:  <\/p>\n<pre><code class=\"cpp\"> 0xe0e0e0 | (31 &lt;&lt; ((0 % 3) &lt;&lt; 3)) = e0e0ff                                                                                                                                                                   0xe0e0e0 | (31 &lt;&lt; ((1 % 3) &lt;&lt; 3)) = e0ffe0                                                                                                                                                                         0xe0e0e0 | (31 &lt;&lt; ((2 % 3) &lt;&lt; 3)) = ffe0e0  <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u0438 \u043c\u0430\u0441\u043a\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 &quot;&amp;&quot; \u043a \u0446\u0432\u0435\u0442\u0443 \u043f\u0438\u043a\u0441\u0435\u043b\u044f, \u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0440\u0438\u0433\u043b\u0443\u0448\u0435\u043d\u043d\u044b\u0435 R \u0438 G, R \u0438 B, G \u0438 B \u043a\u0430\u043d\u0430\u043b\u044b, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043a\u0430\u043a \u044d\u0444\u0444\u0435\u043a\u0442 \u043e\u0442 LCD-\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0430:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/2q\/hm\/mb\/2qhmmblxtw0b7g4f9mjw31f4f9e.png\"><\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0412\u044b\u0434\u0435\u043b\u0438\u043c \u0438\u0445 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;X11\/Xlib.h&gt; #include &lt;sys\/types.h&gt; #include &lt;sys\/stat.h&gt; #include &lt;fcntl.h&gt; #include &lt;unistd.h&gt;  \/* \u041a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_WIDTH (1220) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_HEIGHT (616) \/*! \\brief \u0421\u0434\u0432\u0438\u0433 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0433\u0440\u0430\u043d\u0438 \u043a\u0430\u0440\u0442\u044b \u043e\u0442 \u043b\u0435\u0432\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b *\/ #define IMAGE_SHIFTX (580)  \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u043a\u0441\u0442\u0443\u0440 *\/ #define TEXTURE_COUNT (8) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_HEIGHT (40) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0433\u0440\u0430\u043d\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_TOP_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0433\u0440\u0430\u043d\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_TOP_HEIGHT (32)  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f *\/ #define MAP_WIDTH (19) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f *\/ #define MAP_HEIGHT (19) \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435-\u0447\u0435\u0440\u0442\u0435\u0436\u0435. \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '\\n' *\/ #define MAP_FILEDATA ((MAP_WIDTH + 1) * MAP_HEIGHT) \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 NOR-\u0443\u0437\u043b\u043e\u0432 *\/ #define MAP_ITERATIONS (20)  \/*! \\brief \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0444\u0430\u0439\u043b\u0430-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 *\/ enum map_characters {     MAPCHAR_WIRE  = '.', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434            (ASCII = 46) *\/     MAPCHAR_PLUS  = '+', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434 (\u0435\u0441\u0442\u044c \u0442\u043e\u043a) (ASCII = 43) *\/     MAPCHAR_MINUS = '-', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434 (\u043d\u0435\u0442 \u0442\u043e\u043a\u0430) (ASCII = 45) *\/     MAPCHAR_NOR   = '&gt;', \/**&lt; NOR-\u044d\u043b\u0435\u043c\u0435\u043d\u0442       (ASCII = 62) *\/     MAPCHAR_EMPTY = ' ', \/**&lt; \u041f\u0443\u0441\u0442\u043e\u0439 \u0431\u043b\u043e\u043a       (ASCII = 32) *\/ };  \/*! \\brief \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440 *\/ enum textures_indexes {     TEXINDEX_EMPTY = (0), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u043f\u0443\u0441\u0442\u043e\u0439 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b                 *\/     TEXINDEX_MINUS = (1), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b &quot;\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0430&quot; *\/     TEXINDEX_WIRE  = (2), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0430   *\/     TEXINDEX_PLUS  = (3), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b &quot;\u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0433\u043e&quot; \u043f\u0440\u043e\u0432\u043e\u0434\u0430  *\/     \/**\/     TEXINDEX_NOR   = (6), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b NOR-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430           *\/     TEXINDEX_HOLE  = (7)  \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043e\u0442\u0432\u0435\u0440\u0441\u0442\u0438\u044f \u043d\u0430 \u043f\u043b\u0430\u0442\u0435     *\/ };  \/*! \\brief \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b *\/ enum program_arguments {      ARG_PROGRAM,  \/**&lt; \u0418\u043c\u044f \u0441\u0430\u043c\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b *\/     ARG_BLUEPRINT \/**&lt; \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430   *\/ };  \/*! \\brief \u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.  * \u0422\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043a int \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 *\/ int pixdata[IMAGE_HEIGHT][IMAGE_WIDTH]; \/*! \\brief \u0422\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0431\u043b\u043e\u043a\u043e\u0432, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u044b\u0445 \u043d\u0430 \u043f\u043e\u043b\u0435 *\/ int textures[TEXTURE_COUNT][TEXTURE_HEIGHT][TEXTURE_WIDTH] = { 0 }; \/*! \\brief \u0414\u0430\u043d\u043d\u044b\u0435 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f.   * \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '\\n' *\/ char mapdata[MAP_HEIGHT][MAP_WIDTH + 1]; \/*! \\brief \u0417\u0435\u0440\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b *\/ int random = 2166136261;  \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0438\u0441\u043f\u043b\u0435\u044f Xlib *\/ Display * display; \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430 Xlib *\/ Window window; \/*! \\brief \u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d *\/ XImage * image;  static void _texture_draw(int t, int x, int y);  \/*! \\brief \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438 \u0441\u043e\u043f\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 *\/ static void _image_create(void) {     display = XOpenDisplay(0);     window = XCreateSimpleWindow(display,                                   RootWindow(display, DefaultScreen(display)),                                   0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, 1, 0, 0);     image = XCreateImage(display,                       DefaultVisual(display, DefaultScreen(display)),                       DefaultDepth(display, DefaultScreen(display)),                      2, 0, (char *) pixdata, IMAGE_WIDTH, IMAGE_HEIGHT, 32, 0); }  \/* \\brief \u041e\u0431\u043d\u0443\u043b\u044f\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044f \u0435\u0433\u043e \u0447\u0435\u0440\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c *\/ static void _image_reset(void) {     for (int y = 0; y &lt; IMAGE_HEIGHT; y++)         for (int x = 0; x &lt; IMAGE_WIDTH; x++)             pixdata[y][x] = 0; }  \/*! \\brief \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u0438\u043c\u0432\u043e\u043b \u0438\u0437 \u0447\u0435\u0440\u0442\u0435\u0436\u0430 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] elem \u0421\u0438\u043c\u0432\u043e\u043b \u0447\u0435\u0440\u0442\u0435\u0436\u0430  * \\return \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b *\/ static int _map2texture(char elem) {     return ((elem &gt;&gt; 4) &amp; 1) &lt;&lt; 2 | (elem &amp; 3); }  \/*! \\brief \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u0437 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0430\u0439\u043b\u043e\u0432 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043a\u0430\u0440\u0442\u0435 *\/ static void _image_compile(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)         for (int x = 0; x &lt; MAP_WIDTH; x++)             _texture_draw(_map2texture(mapdata[y][x]), x, y); }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 *\/ static void _image_draw(void) {     XPutImage(display, window,                DefaultGC(display, DefaultScreen(display)),                image, 0, 0, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);     XMapWindow(display, window);     XFlush(display); }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u043e\u0442\u0432\u0435\u0440\u0441\u0442\u0438\u044f \u043d\u0430 \u043f\u0435\u0447\u0430\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0435 *\/ static void _image_drill(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                     _texture_draw(TEXINDEX_HOLE, x, y); }  \/*! \\brief \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0448\u0435\u0439\u0434\u0435\u0440 LCD-\u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f *\/ static void _shader_lcd(int x, int y) {     pixdata[y][x] &amp;= 0xe0e0e0 | (31 &lt;&lt; ((x % 3) &lt;&lt; 3)); }  \/*! \\brief \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0448\u0435\u0439\u0434\u0435\u0440 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0448\u0443\u043c\u0430 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f *\/ static void _shader_noise(int x, int y) {     pixdata[y][x] += 0x0f0f0f &amp; (random *= 16777619); }  \/*! \\brief \u041d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b *\/ static void _image_postprocess(void) {     for (int y = 0; y &lt; IMAGE_HEIGHT; y++)         for (int x = 0; x &lt; IMAGE_WIDTH; x++) {             _shader_lcd(x, y);             _shader_noise(x, y);         } }  \/*! \\brief \u041e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u0445\u043e\u043b\u0441\u0442\u0435 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430  * \\param[in] y Y \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430 *\/ static void _texture_draw(int t, int x, int y) {     for (int ty = 0; ty &lt; TEXTURE_HEIGHT; ty++)         for (int tx = 0; tx &lt; TEXTURE_WIDTH; tx++)             if (textures[t][ty][tx])                 pixdata[ty +                          y * (TEXTURE_TOP_HEIGHT \/ 2) +                          x * (TEXTURE_TOP_HEIGHT \/ 2)]                        [tx +                          IMAGE_SHIFTX +                          x * (TEXTURE_TOP_WIDTH \/ 2) -                          y * TEXTURE_TOP_HEIGHT] = textures[t][ty][tx]; }  \/*! \\brief \u0427\u0438\u0442\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430 \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043a\u0430\u0440\u0442\u0443   * \\param[in] filename \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430 *\/ static void _map_read(const char * filename) {     int f = open(filename, 0);     read(f, mapdata, MAP_FILEDATA);     close(f); }  \/*! \\brief \u0417\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0432\u0445\u043e\u0434\u044b \u0438\u0437 \u0444\u0430\u0439\u043b\u0430-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0432\u0445\u043e\u0434  * \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0430 \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0440\u043e\u043d\u0442\u0430 \u0432\u043e\u043b\u043d\u044b *\/ static void _map_wire_inputs(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)         for (int x = 0; x &lt; MAP_WIDTH; x++)             if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                 mapdata[y][x] = MAPCHAR_WIRE; }  \/*! \\brief \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0437\u0430\u043b\u0438\u0432\u043a\u0443 \u043f\u0440\u043e\u0432\u043e\u0434\u043d\u0438\u043a\u0430 \u043d\u0443\u0436\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c  * \\param[in] t \u0418\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442 \u0430\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430   * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0437\u0430\u043b\u0438\u0432\u043a\u0438  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0437\u0430\u043b\u0438\u0432\u043a\u0438  * \\param[in] c \u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435  * \\param[in] l \u0426\u0435\u043b\u0435\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 *\/ static void _map_fill(int t, int x, int y, int c, int l) {     if ((x &gt;= MAP_WIDTH || y &gt;= MAP_HEIGHT ||           x &lt; 0 || y &lt; 0) || (mapdata[y][x] == l)         || (mapdata[y][x] != c))         return;     mapdata[y][x] = l;     _map_fill(t, x - 1, y, c, l);     _map_fill(t, x + 1, y, c, l);     _map_fill(t, x, y - 1, c, l);     _map_fill(t, x, y + 1, c, l); }  \/*! \\brief \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432\u0445\u043e\u0434\u044b \u0441\u0445\u0435\u043c\u044b \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f  * \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430.  * \\param[in] counter \u0421\u0447\u0435\u0442\u0447\u0438\u043a *\/ static void _map_wire_counter(int counter) {     _map_fill(0, 2, 3,  mapdata[3][2],  counter &amp; 1 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 7,  mapdata[7][2],  counter &amp; 2 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 11, mapdata[11][2], counter &amp; 4 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 15, mapdata[15][2], counter &amp; 8 ? MAPCHAR_PLUS : MAPCHAR_MINUS); }  \/*! \\brief \u041f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u0440\u0430\u0441\u0447\u0435\u0442 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e (\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e) \u0442\u043e\u043a\u0430 \u043f\u043e\u0441\u043b\u0435 NOR-\u0443\u0437\u043b\u0430 *\/ static void _map_process_gates(void) {            for (int i = 0; i &lt; MAP_ITERATIONS; i++)         for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if (mapdata[y][x] == MAPCHAR_NOR)                     _map_fill(0, x + 1, y, mapdata[y][x + 1],                         !(mapdata[y - 1][x] == MAPCHAR_PLUS ? 1 : 0                        || mapdata[y + 1][x] == MAPCHAR_PLUS ? 1 : 0) ?                              MAPCHAR_PLUS : MAPCHAR_MINUS); }  \/* \u041a\u043e\u0434 \u0434\u043e \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  int _x[] = { 15117427, 8413248, 5878632, 13027014, 1 };  void e(int t, int x, int y, int c, int l) {     if ((x &gt;= TEXTURE_WIDTH || y &gt;= TEXTURE_HEIGHT ||           x &lt; 0 || y &lt; 0) ||           (textures[t][y][x] == l) ||           (textures[t][y][x] != c))         return;     textures[t][y][x] = l;     e(t, x - 1, y, c, l);     e(t, x + 1, y, c, l);     e(t, x, y - 1, c, l);     e(t, x, y + 1, c, l); }  void k(int t, int x, int y, int c, int l) {     while (c--) {         textures[t][y][x++] = l;         textures[t][y++][x++] = l;     } }  void r(int t, int x, int y, int c, int l) {     while (c--) {         textures[t][y][x--] = l;         textures[t][y++][x--] = l;     } }  void u(int t, int x, int y, int c, int l) {     while (c--)         textures[t][y++][x] = l; }  char *z[8] = {      (char[]) {4},      (char[]) {6, 1 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16, 0, 0,               21 + 0 * 3 - 0, 16, 1, 63, 21 + 0 * 3 - 0, 16, 2,               63 * 0, 21 - 0, 4, 2, 31 + 0, 36 - 0, 4, 0 + 1,               32 - 1, 5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1, 63,               21 + 1 * 3 - 0, 16, 2, 63 * 1, 21 - 0, 4, 2, 31 + 1,               36 - 0, 4, 6, 1 * 4 + 0, 3, 31, 8 - 0, 6, 1 * 4 + 2,               3, 33, 38 - 0, 6, 1 * 4 + 3, 3, 30, 38 - 0, 4},     (char[]) {5, 1},      (char[]) {6, 0 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16,               0, 0, 21 + 0 * 3 - 0, 16, 1, 63,               21 + 0 * 3 - 0, 16, 2, 63 * 0, 21 - 0,               4, 2, 31 + 0, 36 - 0, 4, 0 + 1, 32 - 1,               5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1,               63, 21 + 1 * 3 - 0, 16, 2, 63 * 1,               21 - 0, 4, 2, 31 + 1, 36 - 0, 4, 6,               0 * 4 + 0, 3, 31, 8 - 0, 6, 0 * 4 + 2,               3, 33, 38 - 0, 6, 0 * 4 + 3, 3, 30,               38 - 0,               4},     (char[]) {4},      (char[]) {4},     (char[]) {6, 2 * 4 + 1, 0 + 0, 32 - 0, 5 - 3, 16, 0, 0,               21 + 0 * 3 - 3, 16, 1, 63, 21 + 0 * 3 - 3, 16, 2, 63 * 0,               21 - 3, 4, 2, 31 + 0, 36 - 3, 4, 0 + 1, 32 - 1, 5 - 3,               16, 0, 0, 21 + 1 * 3 - 3, 16, 1, 63, 21 + 1 * 3 - 3, 16,               2, 63 * 1, 21 - 3, 4, 2, 31 + 1, 36 - 3, 4, 6, 2 * 4 + 0,               3, 31, 8 - 3, 6, 2 * 4 + 2, 3, 33, 38 - 3, 6, 2 * 4 + 3,               3, 30, 38 - 3, 4},      (char[]) {6, 13, 0, 32, 9 + 0, 12 - 0,               0, 8 + 0 + 0, 21, 12 - 0, 1,               31, 9 + 0, 12 - 0, 1,               55 - 0 - 0, 21, 12 - 0, 0,               32, 9 + 3, 12 - 3, 0,               8 + 3 + 3, 21, 12 - 3, 1,               31, 9 + 3, 12 - 3, 1,               55 - 3 - 3, 21, 12 - 3, 6,               14 + 0, 2, 31 + 0, 13, 4,               1 - 0, 31 + 0, 16, 7, 3,               30 + 3 * 0, 14, 6,               12 + 0 * 4, 3, 32 - 0,               11 + 0 * 8, 6, 14 + 1, 2,               31 + 1, 13, 4, 1 - 1,               31 + 1, 16, 7, 3,               30 + 3 * 1, 14, 6,               12 + 1 * 4, 3, 32 - 1,               11 + 1 * 8,               4} };  int main(int argc, char * args[]) {     _image_create();      for (int i = 0; i &lt; 8; i++) {         char *p = z[i];         int c = 0;         while (*p != 4) {             switch (*p) {             case 0:                 k(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 1:                 r(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 2:                 u(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 3:                 e(i, p[1]                   , p[2], 0, c);                 p += 3;                 break;             case 5:                 p = z[p[1]];                 break;             case 6:                 c = _x[p[1] \/ 4] - 1643277 * (p[1] % 4);                 p += 2;                 break;             }         }     }     unsigned int counter = 1;     while (counter++) {         _map_read(args[ARG_BLUEPRINT]);         _map_wire_inputs();         _map_wire_counter(counter);         _map_process_gates();                  _image_reset();                   _image_compile();         _image_drill();         _image_postprocess();                 _image_draw();                  sleep(1);     }      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<h4>\u00abe\u00bb, \u00abk\u00bb, \u00abr\u00bb, \u00abu\u00bb<\/h4>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0435\u0449\u0435 4 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043d\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u0438 \u0438 \u043d\u0435 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043b\u0438 \u2014 \u044d\u0442\u043e \u00abe\u00bb, \u00abk\u00bb, \u00abr\u00bb \u0438 \u00abu\u00bb. \u041f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438\u0445, \u043d\u0435 \u043f\u0440\u0438\u0431\u0435\u0433\u0430\u044f \u043a \u043f\u043e\u0438\u0441\u043a\u0443 \u043c\u0435\u0441\u0442, \u043e\u0442\u043a\u0443\u0434\u0430 \u043e\u043d\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f:  <\/p>\n<pre><code class=\"cpp\">void e(int t, int x, int y, int c, int l) {     if ((x &gt;= TEXTURE_WIDTH || y &gt;= TEXTURE_HEIGHT ||           x &lt; 0 || y &lt; 0) ||           (textures[t][y][x] == l) ||           (textures[t][y][x] != c))         return;     textures[t][y][x] = l;     e(t, x - 1, y, c, l);     e(t, x + 1, y, c, l);     e(t, x, y - 1, c, l);     e(t, x, y + 1, c, l); }<\/code><\/pre>\n<p>  \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a flood_fill, \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430 textures, \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0435\u043c \u0435\u0435 \u0432 _texture_fill.  <\/p>\n<pre><code class=\"cpp\">void k(int t, int x, int y, int c, int l) {     while (c--) {         textures[t][y][x++] = l;         textures[t][y++][x++] = l;     } }  void r(int t, int x, int y, int c, int l) {     while (c--) {         textures[t][y][x--] = l;         textures[t][y++][x--] = l;     } }<\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u00abk\u00bb \u0438 \u00abr\u00bb \u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u0437\u0430\u0434\u0430\u043d\u043d\u0443\u044e \u0435\u0434\u0438\u043d\u0438\u0446\u0443 c \u0440\u0438\u0441\u0443\u044e\u0442 \u0434\u0432\u0430 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c l \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432\u043f\u0440\u0430\u0432\u043e \u0438\u043b\u0438 \u0432\u043b\u0435\u0432\u043e \u043d\u0430 \u0434\u0432\u0430 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0438 \u0432\u043d\u0438\u0437 \u043d\u0430 \u043e\u0434\u0438\u043d \u2014 \u0437\u043d\u0430\u0447\u0438\u0442 \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043b\u0438\u043d\u0438\u0439 SW \u0438 SE. \u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0435\u043c \u0438\u0445 \u0432 _texture_linesw \u0438 _texture_linese.<\/p>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u00abu\u00bb \u0440\u0438\u0441\u0443\u0435\u0442 \u043b\u0438\u043d\u0438\u044e \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e \u0432\u043d\u0438\u0437:  <\/p>\n<pre><code class=\"cpp\">void u(int t, int x, int y, int c, int l) {     while (c--)         textures[t][y++][x] = l; }<\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0435\u043c \u0435\u0451 \u0432 _texture_linedown.  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0412\u0441\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0448\u043b\u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;X11\/Xlib.h&gt; #include &lt;sys\/types.h&gt; #include &lt;sys\/stat.h&gt; #include &lt;fcntl.h&gt; #include &lt;unistd.h&gt;  \/* \u041a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_WIDTH (1220) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_HEIGHT (616) \/*! \\brief \u0421\u0434\u0432\u0438\u0433 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0433\u0440\u0430\u043d\u0438 \u043a\u0430\u0440\u0442\u044b \u043e\u0442 \u043b\u0435\u0432\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b *\/ #define IMAGE_SHIFTX (580)  \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u043a\u0441\u0442\u0443\u0440 *\/ #define TEXTURE_COUNT (8) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_HEIGHT (40) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0433\u0440\u0430\u043d\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_TOP_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0433\u0440\u0430\u043d\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_TOP_HEIGHT (32)  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f *\/ #define MAP_WIDTH (19) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f *\/ #define MAP_HEIGHT (19) \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435-\u0447\u0435\u0440\u0442\u0435\u0436\u0435. \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '\\n' *\/ #define MAP_FILEDATA ((MAP_WIDTH + 1) * MAP_HEIGHT) \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 NOR-\u0443\u0437\u043b\u043e\u0432 *\/ #define MAP_ITERATIONS (20)  \/*! \\brief \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0444\u0430\u0439\u043b\u0430-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 *\/ enum map_characters {     MAPCHAR_WIRE  = '.', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434            (ASCII = 46) *\/     MAPCHAR_PLUS  = '+', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434 (\u0435\u0441\u0442\u044c \u0442\u043e\u043a) (ASCII = 43) *\/     MAPCHAR_MINUS = '-', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434 (\u043d\u0435\u0442 \u0442\u043e\u043a\u0430) (ASCII = 45) *\/     MAPCHAR_NOR   = '&gt;', \/**&lt; NOR-\u044d\u043b\u0435\u043c\u0435\u043d\u0442       (ASCII = 62) *\/     MAPCHAR_EMPTY = ' ', \/**&lt; \u041f\u0443\u0441\u0442\u043e\u0439 \u0431\u043b\u043e\u043a       (ASCII = 32) *\/ };  \/*! \\brief \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440 *\/ enum textures_indexes {     TEXINDEX_EMPTY = (0), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u043f\u0443\u0441\u0442\u043e\u0439 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b                 *\/     TEXINDEX_MINUS = (1), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b &quot;\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0430&quot; *\/     TEXINDEX_WIRE  = (2), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0430   *\/     TEXINDEX_PLUS  = (3), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b &quot;\u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0433\u043e&quot; \u043f\u0440\u043e\u0432\u043e\u0434\u0430  *\/     \/**\/     TEXINDEX_NOR   = (6), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b NOR-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430           *\/     TEXINDEX_HOLE  = (7)  \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043e\u0442\u0432\u0435\u0440\u0441\u0442\u0438\u044f \u043d\u0430 \u043f\u043b\u0430\u0442\u0435     *\/ };  \/*! \\brief \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b *\/ enum program_arguments {      ARG_PROGRAM,  \/**&lt; \u0418\u043c\u044f \u0441\u0430\u043c\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b *\/     ARG_BLUEPRINT \/**&lt; \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430   *\/ };  \/*! \\brief \u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.  * \u0422\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043a int \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 *\/ int pixdata[IMAGE_HEIGHT][IMAGE_WIDTH]; \/*! \\brief \u0422\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0431\u043b\u043e\u043a\u043e\u0432, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u044b\u0445 \u043d\u0430 \u043f\u043e\u043b\u0435 *\/ int textures[TEXTURE_COUNT][TEXTURE_HEIGHT][TEXTURE_WIDTH] = { 0 }; \/*! \\brief \u0414\u0430\u043d\u043d\u044b\u0435 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f.   * \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '\\n' *\/ char mapdata[MAP_HEIGHT][MAP_WIDTH + 1]; \/*! \\brief \u0417\u0435\u0440\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b *\/ int random = 2166136261;  \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0438\u0441\u043f\u043b\u0435\u044f Xlib *\/ Display * display; \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430 Xlib *\/ Window window; \/*! \\brief \u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d *\/ XImage * image;  static void _texture_draw(int t, int x, int y);  \/*! \\brief \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438 \u0441\u043e\u043f\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 *\/ static void _image_create(void) {     display = XOpenDisplay(0);     window = XCreateSimpleWindow(display,                                   RootWindow(display, DefaultScreen(display)),                                   0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, 1, 0, 0);     image = XCreateImage(display,                       DefaultVisual(display, DefaultScreen(display)),                       DefaultDepth(display, DefaultScreen(display)),                      2, 0, (char *) pixdata, IMAGE_WIDTH, IMAGE_HEIGHT, 32, 0); }  \/* \\brief \u041e\u0431\u043d\u0443\u043b\u044f\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044f \u0435\u0433\u043e \u0447\u0435\u0440\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c *\/ static void _image_reset(void) {     for (int y = 0; y &lt; IMAGE_HEIGHT; y++)         for (int x = 0; x &lt; IMAGE_WIDTH; x++)             pixdata[y][x] = 0; }  \/*! \\brief \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u0438\u043c\u0432\u043e\u043b \u0438\u0437 \u0447\u0435\u0440\u0442\u0435\u0436\u0430 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] elem \u0421\u0438\u043c\u0432\u043e\u043b \u0447\u0435\u0440\u0442\u0435\u0436\u0430  * \\return \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b *\/ static int _map2texture(char elem) {     return ((elem &gt;&gt; 4) &amp; 1) &lt;&lt; 2 | (elem &amp; 3); }  \/*! \\brief \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u0437 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0430\u0439\u043b\u043e\u0432 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043a\u0430\u0440\u0442\u0435 *\/ static void _image_compile(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)         for (int x = 0; x &lt; MAP_WIDTH; x++)             _texture_draw(_map2texture(mapdata[y][x]), x, y); }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 *\/ static void _image_draw(void) {     XPutImage(display, window,                DefaultGC(display, DefaultScreen(display)),                image, 0, 0, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);     XMapWindow(display, window);     XFlush(display); }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u043e\u0442\u0432\u0435\u0440\u0441\u0442\u0438\u044f \u043d\u0430 \u043f\u0435\u0447\u0430\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0435 *\/ static void _image_drill(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                     _texture_draw(TEXINDEX_HOLE, x, y); }  \/*! \\brief \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0448\u0435\u0439\u0434\u0435\u0440 LCD-\u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f *\/ static void _shader_lcd(int x, int y) {     pixdata[y][x] &amp;= 0xe0e0e0 | (31 &lt;&lt; ((x % 3) &lt;&lt; 3)); }  \/*! \\brief \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0448\u0435\u0439\u0434\u0435\u0440 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0448\u0443\u043c\u0430 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f *\/ static void _shader_noise(int x, int y) {     pixdata[y][x] += 0x0f0f0f &amp; (random *= 16777619); }  \/*! \\brief \u041d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b *\/ static void _image_postprocess(void) {     for (int y = 0; y &lt; IMAGE_HEIGHT; y++)         for (int x = 0; x &lt; IMAGE_WIDTH; x++) {             _shader_lcd(x, y);             _shader_noise(x, y);         } }  \/*! \\brief \u041e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u0445\u043e\u043b\u0441\u0442\u0435 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430  * \\param[in] y Y \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430 *\/ static void _texture_draw(int t, int x, int y) {     for (int ty = 0; ty &lt; TEXTURE_HEIGHT; ty++)         for (int tx = 0; tx &lt; TEXTURE_WIDTH; tx++)             if (textures[t][ty][tx])                 pixdata[ty +                          y * (TEXTURE_TOP_HEIGHT \/ 2) +                          x * (TEXTURE_TOP_HEIGHT \/ 2)]                        [tx +                          IMAGE_SHIFTX +                          x * (TEXTURE_TOP_WIDTH \/ 2) -                          y * TEXTURE_TOP_HEIGHT] = textures[t][ty][tx]; }  \/*! \\brief \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0437\u0430\u043a\u0440\u0430\u0441\u043a\u0443 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] source \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0446\u0432\u0435\u0442  * \\param[in] target \u041d\u043e\u0432\u044b\u0439 \u0446\u0432\u0435\u0442 *\/ static void _texture_fill(int t, int x, int y, int source, int target) {     if ((x &gt;= TEXTURE_WIDTH || y &gt;= TEXTURE_HEIGHT ||           x &lt; 0 || y &lt; 0) ||           (textures[t][y][x] == target) ||           (textures[t][y][x] != source))         return;     textures[t][y][x] = target;     _texture_fill(t, x - 1, y, source, target);     _texture_fill(t, x + 1, y, source, target);     _texture_fill(t, x, y - 1, source, target);     _texture_fill(t, x, y + 1, source, target); }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u0438\u0437\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043b\u0438\u043d\u0438\u044e \u043f\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e SE  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] c \u0414\u043b\u0438\u043d\u0430 \u043b\u0438\u043d\u0438\u0438 \u043f\u043e \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435  * \\param[in] color \u0426\u0432\u0435\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f *\/ static void _texture_linese(int t, int x, int y, int c, int color) {     while (c--) {         textures[t][y][x++] = color;         textures[t][y++][x++] = color;     } }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u0438\u0437\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043b\u0438\u043d\u0438\u044e \u043f\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e SW  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] c \u0414\u043b\u0438\u043d\u0430 \u043b\u0438\u043d\u0438\u0438 \u043f\u043e \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435  * \\param[in] color \u0426\u0432\u0435\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f *\/ static void _texture_linesw(int t, int x, int y, int c, int color) {     while (c--) {         textures[t][y][x--] = color;         textures[t][y++][x--] = color;     } }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u043b\u0438\u043d\u0438\u044e \u0432\u043d\u0438\u0437  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] c \u0414\u043b\u0438\u043d\u0430 \u043b\u0438\u043d\u0438\u0438  * \\param[in] color \u0426\u0432\u0435\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f *\/ static void _texture_linedown(int t, int x, int y, int c, int color) {     while (c--)         textures[t][y++][x] = color; }  \/*! \\brief \u0427\u0438\u0442\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430 \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043a\u0430\u0440\u0442\u0443   * \\param[in] filename \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430 *\/ static void _map_read(const char * filename) {     int f = open(filename, 0);     read(f, mapdata, MAP_FILEDATA);     close(f); }  \/*! \\brief \u0417\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0432\u0445\u043e\u0434\u044b \u0438\u0437 \u0444\u0430\u0439\u043b\u0430-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0432\u0445\u043e\u0434  * \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0430 \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0440\u043e\u043d\u0442\u0430 \u0432\u043e\u043b\u043d\u044b *\/ static void _map_wire_inputs(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)         for (int x = 0; x &lt; MAP_WIDTH; x++)             if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                 mapdata[y][x] = MAPCHAR_WIRE; }  \/*! \\brief \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0437\u0430\u043b\u0438\u0432\u043a\u0443 \u043f\u0440\u043e\u0432\u043e\u0434\u043d\u0438\u043a\u0430 \u043d\u0443\u0436\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c  * \\param[in] t \u0418\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442 \u0430\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430   * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0437\u0430\u043b\u0438\u0432\u043a\u0438  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0437\u0430\u043b\u0438\u0432\u043a\u0438  * \\param[in] c \u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435  * \\param[in] l \u0426\u0435\u043b\u0435\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 *\/ static void _map_fill(int t, int x, int y, int c, int l) {     if ((x &gt;= MAP_WIDTH || y &gt;= MAP_HEIGHT ||           x &lt; 0 || y &lt; 0) || (mapdata[y][x] == l)         || (mapdata[y][x] != c))         return;     mapdata[y][x] = l;     _map_fill(t, x - 1, y, c, l);     _map_fill(t, x + 1, y, c, l);     _map_fill(t, x, y - 1, c, l);     _map_fill(t, x, y + 1, c, l); }  \/*! \\brief \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432\u0445\u043e\u0434\u044b \u0441\u0445\u0435\u043c\u044b \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f  * \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430.  * \\param[in] counter \u0421\u0447\u0435\u0442\u0447\u0438\u043a *\/ static void _map_wire_counter(int counter) {     _map_fill(0, 2, 3,  mapdata[3][2],  counter &amp; 1 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 7,  mapdata[7][2],  counter &amp; 2 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 11, mapdata[11][2], counter &amp; 4 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 15, mapdata[15][2], counter &amp; 8 ? MAPCHAR_PLUS : MAPCHAR_MINUS); }  \/*! \\brief \u041f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u0440\u0430\u0441\u0447\u0435\u0442 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e (\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e) \u0442\u043e\u043a\u0430 \u043f\u043e\u0441\u043b\u0435 NOR-\u0443\u0437\u043b\u0430 *\/ static void _map_process_gates(void) {            for (int i = 0; i &lt; MAP_ITERATIONS; i++)         for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if (mapdata[y][x] == MAPCHAR_NOR)                     _map_fill(0, x + 1, y, mapdata[y][x + 1],                         !(mapdata[y - 1][x] == MAPCHAR_PLUS ? 1 : 0                        || mapdata[y + 1][x] == MAPCHAR_PLUS ? 1 : 0) ?                              MAPCHAR_PLUS : MAPCHAR_MINUS); }  \/* \u041a\u043e\u0434 \u0434\u043e \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  int _x[] = { 15117427, 8413248, 5878632, 13027014, 1 };  char *z[8] = {      (char[]) {4},      (char[]) {6, 1 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16, 0, 0,               21 + 0 * 3 - 0, 16, 1, 63, 21 + 0 * 3 - 0, 16, 2,               63 * 0, 21 - 0, 4, 2, 31 + 0, 36 - 0, 4, 0 + 1,               32 - 1, 5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1, 63,               21 + 1 * 3 - 0, 16, 2, 63 * 1, 21 - 0, 4, 2, 31 + 1,               36 - 0, 4, 6, 1 * 4 + 0, 3, 31, 8 - 0, 6, 1 * 4 + 2,               3, 33, 38 - 0, 6, 1 * 4 + 3, 3, 30, 38 - 0, 4},     (char[]) {5, 1},      (char[]) {6, 0 * 4 + 1, 0 + 0, 32 - 0, 5 - 0, 16,               0, 0, 21 + 0 * 3 - 0, 16, 1, 63,               21 + 0 * 3 - 0, 16, 2, 63 * 0, 21 - 0,               4, 2, 31 + 0, 36 - 0, 4, 0 + 1, 32 - 1,               5 - 0, 16, 0, 0, 21 + 1 * 3 - 0, 16, 1,               63, 21 + 1 * 3 - 0, 16, 2, 63 * 1,               21 - 0, 4, 2, 31 + 1, 36 - 0, 4, 6,               0 * 4 + 0, 3, 31, 8 - 0, 6, 0 * 4 + 2,               3, 33, 38 - 0, 6, 0 * 4 + 3, 3, 30,               38 - 0,               4},     (char[]) {4},      (char[]) {4},     (char[]) {6, 2 * 4 + 1, 0 + 0, 32 - 0, 5 - 3, 16, 0, 0,               21 + 0 * 3 - 3, 16, 1, 63, 21 + 0 * 3 - 3, 16, 2, 63 * 0,               21 - 3, 4, 2, 31 + 0, 36 - 3, 4, 0 + 1, 32 - 1, 5 - 3,               16, 0, 0, 21 + 1 * 3 - 3, 16, 1, 63, 21 + 1 * 3 - 3, 16,               2, 63 * 1, 21 - 3, 4, 2, 31 + 1, 36 - 3, 4, 6, 2 * 4 + 0,               3, 31, 8 - 3, 6, 2 * 4 + 2, 3, 33, 38 - 3, 6, 2 * 4 + 3,               3, 30, 38 - 3, 4},      (char[]) {6, 13, 0, 32, 9 + 0, 12 - 0,               0, 8 + 0 + 0, 21, 12 - 0, 1,               31, 9 + 0, 12 - 0, 1,               55 - 0 - 0, 21, 12 - 0, 0,               32, 9 + 3, 12 - 3, 0,               8 + 3 + 3, 21, 12 - 3, 1,               31, 9 + 3, 12 - 3, 1,               55 - 3 - 3, 21, 12 - 3, 6,               14 + 0, 2, 31 + 0, 13, 4,               1 - 0, 31 + 0, 16, 7, 3,               30 + 3 * 0, 14, 6,               12 + 0 * 4, 3, 32 - 0,               11 + 0 * 8, 6, 14 + 1, 2,               31 + 1, 13, 4, 1 - 1,               31 + 1, 16, 7, 3,               30 + 3 * 1, 14, 6,               12 + 1 * 4, 3, 32 - 1,               11 + 1 * 8,               4} };  int main(int argc, char * args[]) {     _image_create();      for (int i = 0; i &lt; 8; i++) {         char *p = z[i];         int c = 0;         while (*p != 4) {             switch (*p) {             case 0:                 _texture_linese(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 1:                 _texture_linesw(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 2:                 _texture_linedown(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 3:                 _texture_fill(i, p[1], p[2], 0, c);                 p += 3;                 break;             case 5:                 p = z[p[1]];                 break;             case 6:                 c = _x[p[1] \/ 4] - 1643277 * (p[1] % 4);                 p += 2;                 break;             }         }     }     unsigned int counter = 1;     while (counter++) {         _map_read(args[ARG_BLUEPRINT]);         _map_wire_inputs();         _map_wire_counter(counter);         _map_process_gates();                  _image_reset();                   _image_compile();         _image_drill();         _image_postprocess();                 _image_draw();                  sleep(1);     }      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<h4>\u0412\u0435\u043a\u0442\u043e\u0440\u043d\u0430\u044f \u0433\u0440\u0430\u0444\u0438\u043a\u0430<\/h4>\n<p>  \u041e\u0441\u0442\u0430\u043b\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0430\u0433 \u2014 \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0436\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c, \u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u043c \u00ab\u043d\u0430 \u043f\u043e\u0442\u043e\u043c\u00bb, switch-case:  <\/p>\n<pre><code class=\"cpp\">    for (int i = 0; i &lt; 8; i++) {         char *p = z[i];         int c = 0;         while (*p != 4) {             switch (*p) {             case 0:                 _texture_linese(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 1:                 _texture_linesw(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 2:                 _texture_linedown(i, p[1], p[2], p[3], c);                 p += 4;                 break;             case 3:                 _texture_fill(i, p[1], p[2], 0, c);                 p += 3;                 break;             case 5:                 p = z[p[1]];                 break;             case 6:                 c = _x[p[1] \/ 4] - 1643277 * (p[1] % 4);                 p += 2;                 break;             }         }     }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043c\u0435\u044e\u0442 \u043d\u043e\u0432\u044b\u0435, \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435, \u0438\u043c\u0435\u043d\u0430, \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u00abz\u00bb, \u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u043c\u0441\u044f \u0432 \u043d\u0435\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 0, 5, 5, 8, 2 \u2014 \u00ab\u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u043d\u0438\u044e South-East, \u043e\u0442 [5,5] \u0434\u043b\u0438\u043d\u043e\u0439 8 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u043f\u043e \u043a\u0440\u0430\u0442\u043a\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0446\u0432\u0435\u0442\u043e\u043c \u043d\u043e\u043c\u0435\u0440 2\u00bb) \u0440\u0438\u0441\u0443\u0435\u0442 \u0432\u0435\u0441\u044c \u043d\u0430\u0431\u043e\u0440 \u0442\u0435\u043a\u0441\u0442\u0443\u0440.<br \/>  \u0412\u0440\u043e\u0434\u0435 \u0431\u044b \u0432\u0441\u0451 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043d\u043e \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043d\u0430 \u0446\u0432\u0435\u0442 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0437\u0430\u043c\u0435\u0447\u0435\u043d\u043e \u043d\u0435 \u0431\u044b\u043b\u043e.  <\/p>\n<pre><code class=\"cpp\">c = _x[p[1] \/ 4] - 1643277 * (p[1] % 4);<\/code><\/pre>\n<p>  \u0410\u0433\u0430, \u0437\u043d\u0430\u0447\u0438\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 _x \u2014 \u044d\u0442\u043e \u043f\u0430\u043b\u0438\u0442\u0440\u0430, \u043d\u043e \u0432 \u043e\u0447\u0435\u043d\u044c \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u043c, \u00ab\u0441\u0436\u0430\u0442\u043e\u043c\u00bb, \u0444\u043e\u0440\u043c\u0430\u0442\u0435.  <\/p>\n<pre><code class=\"cpp\">int _x[] = { 15117427, 8413248, 5878632, 13027014, 1 };<\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u043f\u043e\u043a\u0430 \u043d\u0435 \u0437\u043d\u0430\u0435\u043c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u0435\u0433\u043e \u0446\u0432\u0435\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043f\u0430\u043b\u0438\u0442\u0440\u0435 (\u043f\u0440\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0446\u0432\u0435\u0442\u0430 \u0438\u043d\u0434\u0435\u043a\u0441 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 4), \u043f\u0435\u0440\u0435\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u0443\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0438 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u0443\u0435\u043c \u0447\u0438\u0441\u043b\u0430 \u043f\u043e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f\u043c, \u0437\u0430\u043c\u0435\u043d\u0438\u0432 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u043d\u0430 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b:  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0420\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;X11\/Xlib.h&gt; #include &lt;sys\/types.h&gt; #include &lt;sys\/stat.h&gt; #include &lt;fcntl.h&gt; #include &lt;unistd.h&gt;  \/* \u041a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_WIDTH (1220) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_HEIGHT (616) \/*! \\brief \u0421\u0434\u0432\u0438\u0433 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0433\u0440\u0430\u043d\u0438 \u043a\u0430\u0440\u0442\u044b \u043e\u0442 \u043b\u0435\u0432\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b *\/ #define IMAGE_SHIFTX (580)  \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u043a\u0441\u0442\u0443\u0440 *\/ #define TEXTURE_COUNT (8) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_HEIGHT (40) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0433\u0440\u0430\u043d\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_TOP_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0433\u0440\u0430\u043d\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_TOP_HEIGHT (32)  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f *\/ #define MAP_WIDTH (19) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f *\/ #define MAP_HEIGHT (19) \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435-\u0447\u0435\u0440\u0442\u0435\u0436\u0435. \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '\\n' *\/ #define MAP_FILEDATA ((MAP_WIDTH + 1) * MAP_HEIGHT) \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 NOR-\u0443\u0437\u043b\u043e\u0432 *\/ #define MAP_ITERATIONS (20)  \/*! \\brief \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0444\u0430\u0439\u043b\u0430-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 *\/ enum map_characters {     MAPCHAR_WIRE  = '.', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434            (ASCII = 46) *\/     MAPCHAR_PLUS  = '+', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434 (\u0435\u0441\u0442\u044c \u0442\u043e\u043a) (ASCII = 43) *\/     MAPCHAR_MINUS = '-', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434 (\u043d\u0435\u0442 \u0442\u043e\u043a\u0430) (ASCII = 45) *\/     MAPCHAR_NOR   = '&gt;', \/**&lt; NOR-\u044d\u043b\u0435\u043c\u0435\u043d\u0442       (ASCII = 62) *\/     MAPCHAR_EMPTY = ' ', \/**&lt; \u041f\u0443\u0441\u0442\u043e\u0439 \u0431\u043b\u043e\u043a       (ASCII = 32) *\/ };  \/*! \\brief \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440 *\/ enum textures_indexes {     TEXINDEX_EMPTY = (0), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u043f\u0443\u0441\u0442\u043e\u0439 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b                 *\/     TEXINDEX_MINUS = (1), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b &quot;\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0430&quot; *\/     TEXINDEX_WIRE  = (2), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0430   *\/     TEXINDEX_PLUS  = (3), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b &quot;\u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0433\u043e&quot; \u043f\u0440\u043e\u0432\u043e\u0434\u0430  *\/     \/**\/     TEXINDEX_NOR   = (6), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b NOR-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430           *\/     TEXINDEX_HOLE  = (7)  \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043e\u0442\u0432\u0435\u0440\u0441\u0442\u0438\u044f \u043d\u0430 \u043f\u043b\u0430\u0442\u0435     *\/ };  \/*! \\brief \u0421\u043f\u0438\u0441\u043e\u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430 *\/ enum textures_instructions {     TEXVEC_LINESE = (0), \/**&lt; \u041b\u0438\u043d\u0438\u044f SE                          *\/     TEXVEC_LINESW = (1), \/**&lt; \u041b\u0438\u043d\u0438\u044f SW                          *\/     TEXVEC_LINEDW = (2), \/**&lt; \u041b\u0438\u043d\u0438\u044f \u0432\u043d\u0438\u0437                        *\/     TEXVEC_FILL   = (3), \/**&lt; \u0417\u0430\u043b\u0438\u0432\u043a\u0430                           *\/     TEXVEC_EXIT   = (4), \/**&lt; \u041a\u043e\u043d\u0435\u0446 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439           *\/     TEXVEC_REPEAT = (5), \/**&lt; \u041f\u043e\u0432\u0442\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b *\/     TEXVEC_COLOR  = (6)  \/**&lt; \u0412\u044b\u0431\u043e\u0440 \u0446\u0432\u0435\u0442\u0430                       *\/ };  \/*! \\brief \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b *\/ enum program_arguments {      ARG_PROGRAM,  \/**&lt; \u0418\u043c\u044f \u0441\u0430\u043c\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b *\/     ARG_BLUEPRINT \/**&lt; \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430   *\/ };  \/*! \\brief \u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.  * \u0422\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043a int \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 *\/ int pixdata[IMAGE_HEIGHT][IMAGE_WIDTH]; \/*! \\brief \u0422\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0431\u043b\u043e\u043a\u043e\u0432, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u044b\u0445 \u043d\u0430 \u043f\u043e\u043b\u0435 *\/ int textures[TEXTURE_COUNT][TEXTURE_HEIGHT][TEXTURE_WIDTH] = { 0 }; \/*! \\brief \u0414\u0430\u043d\u043d\u044b\u0435 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f.   * \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '\\n' *\/ char mapdata[MAP_HEIGHT][MAP_WIDTH + 1]; \/*! \\brief \u0417\u0435\u0440\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b *\/ int random = 2166136261;  \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0438\u0441\u043f\u043b\u0435\u044f Xlib *\/ Display * display; \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430 Xlib *\/ Window window; \/*! \\brief \u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d *\/ XImage * image;  \/*! \\brief \u0412\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440 *\/ static const char * vecdata[TEXTURE_COUNT] = {      \/* TEXINDEX_EMPTY *\/     (char[]) { TEXVEC_EXIT },      \/* TEXINDEX_MINUS *\/     (char[]) { TEXVEC_COLOR,   5,            TEXVEC_LINESE, 32,  5, 16,                 TEXVEC_LINESE,  0, 21, 16,    TEXVEC_LINESW, 63, 21, 16,                 TEXVEC_LINEDW,  0, 21,  4,    TEXVEC_LINEDW, 31, 36,  4,                 TEXVEC_LINESW, 31,  5, 16,    TEXVEC_LINESE,  0, 24, 16,                 TEXVEC_LINESW, 63, 24, 16,    TEXVEC_LINEDW, 63, 21,  4,                 TEXVEC_LINEDW, 32, 36,  4,    TEXVEC_COLOR,   4,                 TEXVEC_FILL,   31, 8,         TEXVEC_COLOR,   6,                TEXVEC_FILL,   33, 38,        TEXVEC_COLOR,   7,                 TEXVEC_FILL,   30, 38,        TEXVEC_EXIT },     \/* TEXINDEX_WIRE *\/     (char[]) { TEXVEC_REPEAT,  1 },      \/* TEXINDEX_PLUS *\/     (char[]) { TEXVEC_COLOR,   1,            TEXVEC_LINESE, 32,  5, 16,                TEXVEC_LINESE,  0, 21, 16,    TEXVEC_LINESW, 63, 21, 16,                 TEXVEC_LINEDW, 63, 21,  4,    TEXVEC_LINEDW, 31, 36,  4,                 TEXVEC_LINESW, 31,  5, 16,    TEXVEC_LINESE,  0, 24, 16,                 TEXVEC_LINESW, 63, 24, 16,    TEXVEC_LINEDW, 63, 21,  4,                 TEXVEC_LINEDW, 32, 36,  4,    TEXVEC_COLOR,   0,                 TEXVEC_FILL,   31,  8,        TEXVEC_COLOR,   2,                TEXVEC_FILL,   33, 38,        TEXVEC_COLOR,   3,                 TEXVEC_FILL,   30, 38,        TEXVEC_EXIT },     \/* \u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f *\/     (char[]) { TEXVEC_EXIT },      \/* \u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f *\/     (char[]) { TEXVEC_EXIT },     \/* TEXINDEX_NOR *\/     (char[]) { TEXVEC_COLOR,   9,            TEXVEC_LINESE, 32,  2, 16,                 TEXVEC_LINESE,  0, 18, 16,    TEXVEC_LINESW, 63, 18, 16,                 TEXVEC_LINEDW,  0, 18,  4,    TEXVEC_LINEDW, 31, 33,  4,                 TEXVEC_LINESW, 31,  2, 16,    TEXVEC_LINESE,  0, 21, 16,                 TEXVEC_LINESW, 63, 21, 16,    TEXVEC_LINEDW, 63, 18,  4,                 TEXVEC_LINEDW, 32, 33,  4,    TEXVEC_COLOR,   8,                TEXVEC_FILL,   31,  5,        TEXVEC_COLOR,  10,                  TEXVEC_FILL,   33, 35,        TEXVEC_COLOR,  11,                TEXVEC_FILL,   30, 35,        TEXVEC_EXIT },      \/* TEXINDEX_HOLE *\/     (char[]) { TEXVEC_COLOR,  13,            TEXVEC_LINESE, 32, 9, 12,                 TEXVEC_LINESE,  8, 21, 12,    TEXVEC_LINESW, 31, 9, 12,                 TEXVEC_LINESW, 55, 21, 12,    TEXVEC_LINESE, 32, 12, 9,                 TEXVEC_LINESE, 14, 21,  9,    TEXVEC_LINESW, 31, 12, 9,                 TEXVEC_LINESW, 49, 21,  9,    TEXVEC_COLOR,  14,                 TEXVEC_LINEDW, 31, 13,  4,    TEXVEC_LINESW, 31, 16, 7,                 TEXVEC_FILL,   30, 14,        TEXVEC_COLOR,  12,                 TEXVEC_FILL,   32, 11,        TEXVEC_COLOR,  15,                 TEXVEC_LINEDW, 32, 13,  4,    TEXVEC_LINESE, 32, 16, 7,                 TEXVEC_FILL,   33, 14,        TEXVEC_COLOR,  16,                 TEXVEC_FILL,   31, 19,        TEXVEC_EXIT } };  static void _texture_draw(int t, int x, int y);  \/*! \\brief \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438 \u0441\u043e\u043f\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 *\/ static void _image_create(void) {     display = XOpenDisplay(0);     window = XCreateSimpleWindow(display,                                   RootWindow(display, DefaultScreen(display)),                                   0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, 1, 0, 0);     image = XCreateImage(display,                       DefaultVisual(display, DefaultScreen(display)),                       DefaultDepth(display, DefaultScreen(display)),                      2, 0, (char *) pixdata, IMAGE_WIDTH, IMAGE_HEIGHT, 32, 0); }  \/* \\brief \u041e\u0431\u043d\u0443\u043b\u044f\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044f \u0435\u0433\u043e \u0447\u0435\u0440\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c *\/ static void _image_reset(void) {     for (int y = 0; y &lt; IMAGE_HEIGHT; y++)         for (int x = 0; x &lt; IMAGE_WIDTH; x++)             pixdata[y][x] = 0; }  \/*! \\brief \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u0438\u043c\u0432\u043e\u043b \u0438\u0437 \u0447\u0435\u0440\u0442\u0435\u0436\u0430 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] elem \u0421\u0438\u043c\u0432\u043e\u043b \u0447\u0435\u0440\u0442\u0435\u0436\u0430  * \\return \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b *\/ static int _map2texture(char elem) {     return ((elem &gt;&gt; 4) &amp; 1) &lt;&lt; 2 | (elem &amp; 3); }  \/*! \\brief \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u0437 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0430\u0439\u043b\u043e\u0432 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043a\u0430\u0440\u0442\u0435 *\/ static void _image_compile(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)         for (int x = 0; x &lt; MAP_WIDTH; x++)             _texture_draw(_map2texture(mapdata[y][x]), x, y); }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 *\/ static void _image_draw(void) {     XPutImage(display, window,                DefaultGC(display, DefaultScreen(display)),                image, 0, 0, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);     XMapWindow(display, window);     XFlush(display); }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u043e\u0442\u0432\u0435\u0440\u0441\u0442\u0438\u044f \u043d\u0430 \u043f\u0435\u0447\u0430\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0435 *\/ static void _image_drill(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                     _texture_draw(TEXINDEX_HOLE, x, y); }  \/*! \\brief \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0448\u0435\u0439\u0434\u0435\u0440 LCD-\u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f *\/ static void _shader_lcd(int x, int y) {     pixdata[y][x] &amp;= 0xe0e0e0 | (31 &lt;&lt; ((x % 3) &lt;&lt; 3)); }  \/*! \\brief \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0448\u0435\u0439\u0434\u0435\u0440 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0448\u0443\u043c\u0430 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f *\/ static void _shader_noise(int x, int y) {     pixdata[y][x] += 0x0f0f0f &amp; (random *= 16777619); }  \/*! \\brief \u041d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b *\/ static void _image_postprocess(void) {     for (int y = 0; y &lt; IMAGE_HEIGHT; y++)         for (int x = 0; x &lt; IMAGE_WIDTH; x++) {             _shader_lcd(x, y);             _shader_noise(x, y);         } }  \/*! \\brief \u041e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u0445\u043e\u043b\u0441\u0442\u0435 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430  * \\param[in] y Y \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430 *\/ static void _texture_draw(int t, int x, int y) {     for (int ty = 0; ty &lt; TEXTURE_HEIGHT; ty++)         for (int tx = 0; tx &lt; TEXTURE_WIDTH; tx++)             if (textures[t][ty][tx])                 pixdata[ty +                          y * (TEXTURE_TOP_HEIGHT \/ 2) +                          x * (TEXTURE_TOP_HEIGHT \/ 2)]                        [tx +                          IMAGE_SHIFTX +                          x * (TEXTURE_TOP_WIDTH \/ 2) -                          y * TEXTURE_TOP_HEIGHT] = textures[t][ty][tx]; }  \/*! \\brief \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0437\u0430\u043a\u0440\u0430\u0441\u043a\u0443 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] source \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0446\u0432\u0435\u0442  * \\param[in] target \u041d\u043e\u0432\u044b\u0439 \u0446\u0432\u0435\u0442 *\/ static void _texture_fill(int t, int x, int y, int source, int target) {     if ((x &gt;= TEXTURE_WIDTH || y &gt;= TEXTURE_HEIGHT ||           x &lt; 0 || y &lt; 0) ||           (textures[t][y][x] == target) ||           (textures[t][y][x] != source))         return;     textures[t][y][x] = target;     _texture_fill(t, x - 1, y, source, target);     _texture_fill(t, x + 1, y, source, target);     _texture_fill(t, x, y - 1, source, target);     _texture_fill(t, x, y + 1, source, target); }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u0438\u0437\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043b\u0438\u043d\u0438\u044e \u043f\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e SE  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] c \u0414\u043b\u0438\u043d\u0430 \u043b\u0438\u043d\u0438\u0438 \u043f\u043e \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435  * \\param[in] color \u0426\u0432\u0435\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f *\/ static void _texture_linese(int t, int x, int y, int c, int color) {     while (c--) {         textures[t][y][x++] = color;         textures[t][y++][x++] = color;     } }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u0438\u0437\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043b\u0438\u043d\u0438\u044e \u043f\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e SW  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] c \u0414\u043b\u0438\u043d\u0430 \u043b\u0438\u043d\u0438\u0438 \u043f\u043e \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435  * \\param[in] color \u0426\u0432\u0435\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f *\/ static void _texture_linesw(int t, int x, int y, int c, int color) {     while (c--) {         textures[t][y][x--] = color;         textures[t][y++][x--] = color;     } }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u043b\u0438\u043d\u0438\u044e \u0432\u043d\u0438\u0437  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] c \u0414\u043b\u0438\u043d\u0430 \u043b\u0438\u043d\u0438\u0438  * \\param[in] color \u0426\u0432\u0435\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f *\/ static void _texture_linedown(int t, int x, int y, int c, int color) {     while (c--)         textures[t][y++][x] = color; }  \/*! \\brief \u0427\u0438\u0442\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430 \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043a\u0430\u0440\u0442\u0443   * \\param[in] filename \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430 *\/ static void _map_read(const char * filename) {     int f = open(filename, 0);     read(f, mapdata, MAP_FILEDATA);     close(f); }  \/*! \\brief \u0417\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0432\u0445\u043e\u0434\u044b \u0438\u0437 \u0444\u0430\u0439\u043b\u0430-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0432\u0445\u043e\u0434  * \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0430 \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0440\u043e\u043d\u0442\u0430 \u0432\u043e\u043b\u043d\u044b *\/ static void _map_wire_inputs(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)         for (int x = 0; x &lt; MAP_WIDTH; x++)             if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                 mapdata[y][x] = MAPCHAR_WIRE; }  \/*! \\brief \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0437\u0430\u043b\u0438\u0432\u043a\u0443 \u043f\u0440\u043e\u0432\u043e\u0434\u043d\u0438\u043a\u0430 \u043d\u0443\u0436\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c  * \\param[in] t \u0418\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442 \u0430\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430   * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0437\u0430\u043b\u0438\u0432\u043a\u0438  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0437\u0430\u043b\u0438\u0432\u043a\u0438  * \\param[in] c \u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435  * \\param[in] l \u0426\u0435\u043b\u0435\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 *\/ static void _map_fill(int t, int x, int y, int c, int l) {     if ((x &gt;= MAP_WIDTH || y &gt;= MAP_HEIGHT ||           x &lt; 0 || y &lt; 0) || (mapdata[y][x] == l)         || (mapdata[y][x] != c))         return;     mapdata[y][x] = l;     _map_fill(t, x - 1, y, c, l);     _map_fill(t, x + 1, y, c, l);     _map_fill(t, x, y - 1, c, l);     _map_fill(t, x, y + 1, c, l); }  \/*! \\brief \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432\u0445\u043e\u0434\u044b \u0441\u0445\u0435\u043c\u044b \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f  * \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430.  * \\param[in] counter \u0421\u0447\u0435\u0442\u0447\u0438\u043a *\/ static void _map_wire_counter(int counter) {     _map_fill(0, 2, 3,  mapdata[3][2],  counter &amp; 1 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 7,  mapdata[7][2],  counter &amp; 2 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 11, mapdata[11][2], counter &amp; 4 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 15, mapdata[15][2], counter &amp; 8 ? MAPCHAR_PLUS : MAPCHAR_MINUS); }  \/*! \\brief \u041f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u0440\u0430\u0441\u0447\u0435\u0442 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e (\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e) \u0442\u043e\u043a\u0430 \u043f\u043e\u0441\u043b\u0435 NOR-\u0443\u0437\u043b\u0430 *\/ static void _map_process_gates(void) {            for (int i = 0; i &lt; MAP_ITERATIONS; i++)         for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if (mapdata[y][x] == MAPCHAR_NOR)                     _map_fill(0, x + 1, y, mapdata[y][x + 1],                         !(mapdata[y - 1][x] == MAPCHAR_PLUS ? 1 : 0                        || mapdata[y + 1][x] == MAPCHAR_PLUS ? 1 : 0) ?                              MAPCHAR_PLUS : MAPCHAR_MINUS); }  \/* \u041a\u043e\u0434 \u0434\u043e \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  int _x[] = { 15117427, 8413248, 5878632, 13027014, 1 };  int main(int argc, char * args[]) {     _image_create();      for (int tex = 0; tex &lt; TEXTURE_COUNT; tex++) {         char * ptr = vecdata[tex];         int c = 0;         while (*ptr != TEXVEC_EXIT) {             switch (*ptr) {             case TEXVEC_LINESE:                 _texture_linese(tex, ptr[1], ptr[2], ptr[3], c);                 ptr += 4;                 break;             case TEXVEC_LINESW:                 _texture_linesw(tex, ptr[1], ptr[2], ptr[3], c);                 ptr += 4;                 break;             case TEXVEC_LINEDW:                 _texture_linedown(tex, ptr[1], ptr[2], ptr[3], c);                 ptr += 4;                 break;             case TEXVEC_FILL:                 _texture_fill(tex, ptr[1], ptr[2], 0, c);                 ptr += 3;                 break;             case TEXVEC_REPEAT:                 ptr = vecdata[ptr[1]];                 break;             case TEXVEC_COLOR:                 c = _x[ptr[1] \/ 4] - 1643277 * (ptr[1] % 4);                 ptr += 2;                 break;             }         }     }     unsigned int counter = 1;     while (counter++) {         _map_read(args[ARG_BLUEPRINT]);         _map_wire_inputs();         _map_wire_counter(counter);         _map_process_gates();                  _image_reset();                   _image_compile();         _image_drill();         _image_postprocess();                 _image_draw();                  sleep(1);     }      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0441\u043b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u00abTEXVEC_COLOR\u00bb \u2014 \u044d\u0442\u043e 16. \u041d\u0430\u043f\u0438\u0448\u0435\u043c <a href=\"https:\/\/onlinegdb.com\/Hy95lQdQP\" rel=\"nofollow\">\u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439<\/a> \u043a\u043e\u0434, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/oc\/ln\/uf\/oclnufqp1-eipsijlffj7m-ilma.png\"><br \/>  \u0422\u0435\u043f\u0435\u0440\u044c, \u0438\u043c\u0435\u044f \u043d\u0430 \u0440\u0443\u043a\u0430\u0445 \u043f\u0430\u043b\u0438\u0442\u0440\u0443 \u0432 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0435\u0451 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u0434\u043b\u044f \u0446\u0432\u0435\u0442\u043e\u0432 \u0432 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0430 \u0437\u0430\u043e\u0434\u043d\u043e \u0438 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440:  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;X11\/Xlib.h&gt; #include &lt;sys\/types.h&gt; #include &lt;sys\/stat.h&gt; #include &lt;fcntl.h&gt; #include &lt;unistd.h&gt;  \/* \u041a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 *\/  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_WIDTH (1220) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define IMAGE_HEIGHT (616) \/*! \\brief \u0421\u0434\u0432\u0438\u0433 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0433\u0440\u0430\u043d\u0438 \u043a\u0430\u0440\u0442\u044b \u043e\u0442 \u043b\u0435\u0432\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b *\/ #define IMAGE_SHIFTX (580)  \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u043a\u0441\u0442\u0443\u0440 *\/ #define TEXTURE_COUNT (8) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_HEIGHT (40) \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u0433\u0440\u0430\u043d\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_TOP_WIDTH (64) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u0433\u0440\u0430\u043d\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 *\/ #define TEXTURE_TOP_HEIGHT (32)  \/*! \\brief \u0428\u0438\u0440\u0438\u043d\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f *\/ #define MAP_WIDTH (19) \/*! \\brief \u0412\u044b\u0441\u043e\u0442\u0430 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f *\/ #define MAP_HEIGHT (19) \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435-\u0447\u0435\u0440\u0442\u0435\u0436\u0435. \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '\\n' *\/ #define MAP_FILEDATA ((MAP_WIDTH + 1) * MAP_HEIGHT) \/*! \\brief \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 NOR-\u0443\u0437\u043b\u043e\u0432 *\/ #define MAP_ITERATIONS (20)  \/*! \\brief \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0444\u0430\u0439\u043b\u0430-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 *\/ enum map_characters {     MAPCHAR_WIRE  = '.', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434            (ASCII = 46) *\/     MAPCHAR_PLUS  = '+', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434 (\u0435\u0441\u0442\u044c \u0442\u043e\u043a) (ASCII = 43) *\/     MAPCHAR_MINUS = '-', \/**&lt; \u041f\u0440\u043e\u0432\u043e\u0434 (\u043d\u0435\u0442 \u0442\u043e\u043a\u0430) (ASCII = 45) *\/     MAPCHAR_NOR   = '&gt;', \/**&lt; NOR-\u044d\u043b\u0435\u043c\u0435\u043d\u0442       (ASCII = 62) *\/     MAPCHAR_EMPTY = ' ', \/**&lt; \u041f\u0443\u0441\u0442\u043e\u0439 \u0431\u043b\u043e\u043a       (ASCII = 32) *\/ };  \/*! \\brief \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440 *\/ enum textures_indexes {     TEXINDEX_EMPTY = (0), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u043f\u0443\u0441\u0442\u043e\u0439 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b                 *\/     TEXINDEX_MINUS = (1), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b &quot;\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0430&quot; *\/     TEXINDEX_WIRE  = (2), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0430   *\/     TEXINDEX_PLUS  = (3), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b &quot;\u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0433\u043e&quot; \u043f\u0440\u043e\u0432\u043e\u0434\u0430  *\/     \/**\/     TEXINDEX_NOR   = (6), \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b NOR-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430           *\/     TEXINDEX_HOLE  = (7)  \/**&lt; \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043e\u0442\u0432\u0435\u0440\u0441\u0442\u0438\u044f \u043d\u0430 \u043f\u043b\u0430\u0442\u0435     *\/ };  \/*! \\brief \u0421\u043f\u0438\u0441\u043e\u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430 *\/ enum textures_instructions {     TEXVEC_LINESE = (0), \/**&lt; \u041b\u0438\u043d\u0438\u044f SE                          *\/     TEXVEC_LINESW = (1), \/**&lt; \u041b\u0438\u043d\u0438\u044f SW                          *\/     TEXVEC_LINEDW = (2), \/**&lt; \u041b\u0438\u043d\u0438\u044f \u0432\u043d\u0438\u0437                        *\/     TEXVEC_FILL   = (3), \/**&lt; \u0417\u0430\u043b\u0438\u0432\u043a\u0430                           *\/     TEXVEC_EXIT   = (4), \/**&lt; \u041a\u043e\u043d\u0435\u0446 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439           *\/     TEXVEC_REPEAT = (5), \/**&lt; \u041f\u043e\u0432\u0442\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b *\/     TEXVEC_COLOR  = (6)  \/**&lt; \u0412\u044b\u0431\u043e\u0440 \u0446\u0432\u0435\u0442\u0430                       *\/ };  \/*! \\brief \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b *\/ enum program_arguments {      ARG_PROGRAM,  \/**&lt; \u0418\u043c\u044f \u0441\u0430\u043c\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b *\/     ARG_BLUEPRINT \/**&lt; \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430   *\/ };  \/*! \\brief \u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.  * \u0422\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043a int \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432 *\/ int pixdata[IMAGE_HEIGHT][IMAGE_WIDTH]; \/*! \\brief \u0422\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0431\u043b\u043e\u043a\u043e\u0432, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u044b\u0445 \u043d\u0430 \u043f\u043e\u043b\u0435 *\/ int textures[TEXTURE_COUNT][TEXTURE_HEIGHT][TEXTURE_WIDTH] = { 0 }; \/*! \\brief \u0414\u0430\u043d\u043d\u044b\u0435 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f.   * \u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 '\\n' *\/ char mapdata[MAP_HEIGHT][MAP_WIDTH + 1]; \/*! \\brief \u0417\u0435\u0440\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b *\/ int random = 2166136261;  \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0438\u0441\u043f\u043b\u0435\u044f Xlib *\/ Display * display; \/*! \\brief \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043e\u043a\u043d\u0430 Xlib *\/ Window window; \/*! \\brief \u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d *\/ XImage * image;  \/*! \\brief \u041f\u0430\u043b\u0438\u0442\u0440\u0430 \u0446\u0432\u0435\u0442\u043e\u0432 \u0434\u043b\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438   * \\note \u0427\u0435\u0440\u043d\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u0446\u0432\u0435\u0442 {001} \u0434\u043b\u044f \u043e\u0442\u043b\u0438\u0447\u0438\u044f \u043e\u0442 &quot;\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0433\u043e&quot; \u0447\u0435\u0440\u043d\u043e\u0433\u043e {000} *\/ static const int texturepalette[] = {                           \/*  \u0421\u0432\u0435\u0442\u043b\u0435\u0435   \u2581\u2581\u2582\u2582\u2583\u2583\u2584\u2584\u2585\u2585\u2586\u2586\u2587\u2587\u2588\u2588   \u0422\u0435\u043c\u043d\u0435\u0435 *\/         \/* \u0421\u0432\u0435\u0442\u043b\u043e-\u043a\u043e\u0440\u0438\u0447\u043d\u0435\u0432\u044b\u0439 *\/ 0xe6ac73, 0xcd9966, 0xb48659, 0x9b734c,     \/* \u0422\u0435\u043c\u043d\u043e-\u043a\u043e\u0440\u0438\u0447\u043d\u0435\u0432\u044b\u0439  *\/ 0x806040, 0x674d33, 0x4e3a26, 0x352719,     \/* \u0417\u0435\u043b\u0435\u043d\u044b\u0439           *\/ 0x59b368, 0x40a05b, 0x278d4e, 0x0e7a41,     \/* \u0421\u0435\u0440\u044b\u0439             *\/ 0xc6c6c6, 0xadb3b9, 0x94a0ac, 0x7b8d9f,     \/* \u0427\u0435\u0440\u043d\u044b\u0439            *\/ 0x000001 };  \/*! \\brief \u0412\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440 *\/ static const char * vecdata[TEXTURE_COUNT] = {      \/* TEXINDEX_EMPTY *\/     (char[]) { TEXVEC_EXIT },      \/* TEXINDEX_MINUS *\/     (char[]) { TEXVEC_COLOR,   5,            TEXVEC_LINESE, 32,  5, 16,                 TEXVEC_LINESE,  0, 21, 16,    TEXVEC_LINESW, 63, 21, 16,                 TEXVEC_LINEDW,  0, 21,  4,    TEXVEC_LINEDW, 31, 36,  4,                 TEXVEC_LINESW, 31,  5, 16,    TEXVEC_LINESE,  0, 24, 16,                 TEXVEC_LINESW, 63, 24, 16,    TEXVEC_LINEDW, 63, 21,  4,                 TEXVEC_LINEDW, 32, 36,  4,    TEXVEC_COLOR,   4,                 TEXVEC_FILL,   31, 8,         TEXVEC_COLOR,   6,                TEXVEC_FILL,   33, 38,        TEXVEC_COLOR,   7,                 TEXVEC_FILL,   30, 38,        TEXVEC_EXIT },     \/* TEXINDEX_WIRE *\/     (char[]) { TEXVEC_REPEAT,  1 },      \/* TEXINDEX_PLUS *\/     (char[]) { TEXVEC_COLOR,   1,            TEXVEC_LINESE, 32,  5, 16,                TEXVEC_LINESE,  0, 21, 16,    TEXVEC_LINESW, 63, 21, 16,                 TEXVEC_LINEDW, 63, 21,  4,    TEXVEC_LINEDW, 31, 36,  4,                 TEXVEC_LINESW, 31,  5, 16,    TEXVEC_LINESE,  0, 24, 16,                 TEXVEC_LINESW, 63, 24, 16,    TEXVEC_LINEDW, 63, 21,  4,                 TEXVEC_LINEDW, 32, 36,  4,    TEXVEC_COLOR,   0,                 TEXVEC_FILL,   31,  8,        TEXVEC_COLOR,   2,                TEXVEC_FILL,   33, 38,        TEXVEC_COLOR,   3,                 TEXVEC_FILL,   30, 38,        TEXVEC_EXIT },     \/* \u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f *\/     (char[]) { TEXVEC_EXIT },      \/* \u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f *\/     (char[]) { TEXVEC_EXIT },     \/* TEXINDEX_NOR *\/     (char[]) { TEXVEC_COLOR,   9,            TEXVEC_LINESE, 32,  2, 16,                 TEXVEC_LINESE,  0, 18, 16,    TEXVEC_LINESW, 63, 18, 16,                 TEXVEC_LINEDW,  0, 18,  4,    TEXVEC_LINEDW, 31, 33,  4,                 TEXVEC_LINESW, 31,  2, 16,    TEXVEC_LINESE,  0, 21, 16,                 TEXVEC_LINESW, 63, 21, 16,    TEXVEC_LINEDW, 63, 18,  4,                 TEXVEC_LINEDW, 32, 33,  4,    TEXVEC_COLOR,   8,                TEXVEC_FILL,   31,  5,        TEXVEC_COLOR,  10,                  TEXVEC_FILL,   33, 35,        TEXVEC_COLOR,  11,                TEXVEC_FILL,   30, 35,        TEXVEC_EXIT },      \/* TEXINDEX_HOLE *\/     (char[]) { TEXVEC_COLOR,  13,            TEXVEC_LINESE, 32, 9, 12,                 TEXVEC_LINESE,  8, 21, 12,    TEXVEC_LINESW, 31, 9, 12,                 TEXVEC_LINESW, 55, 21, 12,    TEXVEC_LINESE, 32, 12, 9,                 TEXVEC_LINESE, 14, 21,  9,    TEXVEC_LINESW, 31, 12, 9,                 TEXVEC_LINESW, 49, 21,  9,    TEXVEC_COLOR,  14,                 TEXVEC_LINEDW, 31, 13,  4,    TEXVEC_LINESW, 31, 16, 7,                 TEXVEC_FILL,   30, 14,        TEXVEC_COLOR,  12,                 TEXVEC_FILL,   32, 11,        TEXVEC_COLOR,  15,                 TEXVEC_LINEDW, 32, 13,  4,    TEXVEC_LINESE, 32, 16, 7,                 TEXVEC_FILL,   33, 14,        TEXVEC_COLOR,  16,                 TEXVEC_FILL,   31, 19,        TEXVEC_EXIT } };  static void _texture_draw(int t, int x, int y);  \/*! \\brief \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438 \u0441\u043e\u043f\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 *\/ static void _image_create(void) {     display = XOpenDisplay(0);     window = XCreateSimpleWindow(display,                                   RootWindow(display, DefaultScreen(display)),                                   0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, 1, 0, 0);     image = XCreateImage(display,                       DefaultVisual(display, DefaultScreen(display)),                       DefaultDepth(display, DefaultScreen(display)),                      2, 0, (char *) pixdata, IMAGE_WIDTH, IMAGE_HEIGHT, 32, 0); }  \/* \\brief \u041e\u0431\u043d\u0443\u043b\u044f\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044f \u0435\u0433\u043e \u0447\u0435\u0440\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c *\/ static void _image_reset(void) {     for (int y = 0; y &lt; IMAGE_HEIGHT; y++)         for (int x = 0; x &lt; IMAGE_WIDTH; x++)             pixdata[y][x] = 0; }  \/*! \\brief \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u0438\u043c\u0432\u043e\u043b \u0438\u0437 \u0447\u0435\u0440\u0442\u0435\u0436\u0430 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] elem \u0421\u0438\u043c\u0432\u043e\u043b \u0447\u0435\u0440\u0442\u0435\u0436\u0430  * \\return \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b *\/ static int _map2texture(char elem) {     return ((elem &gt;&gt; 4) &amp; 1) &lt;&lt; 2 | (elem &amp; 3); }  \/*! \\brief \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u0437 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0430\u0439\u043b\u043e\u0432 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043a\u0430\u0440\u0442\u0435 *\/ static void _image_compile(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)         for (int x = 0; x &lt; MAP_WIDTH; x++)             _texture_draw(_map2texture(mapdata[y][x]), x, y); }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 *\/ static void _image_draw(void) {     XPutImage(display, window,                DefaultGC(display, DefaultScreen(display)),                image, 0, 0, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);     XMapWindow(display, window);     XFlush(display); }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u043e\u0442\u0432\u0435\u0440\u0441\u0442\u0438\u044f \u043d\u0430 \u043f\u0435\u0447\u0430\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0435 *\/ static void _image_drill(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                     _texture_draw(TEXINDEX_HOLE, x, y); }  \/*! \\brief \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0448\u0435\u0439\u0434\u0435\u0440 LCD-\u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f *\/ static void _shader_lcd(int x, int y) {     pixdata[y][x] &amp;= 0xe0e0e0 | (31 &lt;&lt; ((x % 3) &lt;&lt; 3)); }  \/*! \\brief \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0448\u0435\u0439\u0434\u0435\u0440 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0448\u0443\u043c\u0430 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f *\/ static void _shader_noise(int x, int y) {     pixdata[y][x] += 0x0f0f0f &amp; (random *= 16777619); }  \/*! \\brief \u041d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b *\/ static void _image_postprocess(void) {     for (int y = 0; y &lt; IMAGE_HEIGHT; y++)         for (int x = 0; x &lt; IMAGE_WIDTH; x++) {             _shader_lcd(x, y);             _shader_noise(x, y);         } }  \/*! \\brief \u041e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u0445\u043e\u043b\u0441\u0442\u0435 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430  * \\param[in] y Y \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0442\u0430\u0439\u043b\u0430 *\/ static void _texture_draw(int t, int x, int y) {     for (int ty = 0; ty &lt; TEXTURE_HEIGHT; ty++)         for (int tx = 0; tx &lt; TEXTURE_WIDTH; tx++)             if (textures[t][ty][tx])                 pixdata[ty +                          y * (TEXTURE_TOP_HEIGHT \/ 2) +                          x * (TEXTURE_TOP_HEIGHT \/ 2)]                        [tx +                          IMAGE_SHIFTX +                          x * (TEXTURE_TOP_WIDTH \/ 2) -                          y * TEXTURE_TOP_HEIGHT] = textures[t][ty][tx]; }  \/*! \\brief \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0437\u0430\u043a\u0440\u0430\u0441\u043a\u0443 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] source \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0446\u0432\u0435\u0442  * \\param[in] target \u041d\u043e\u0432\u044b\u0439 \u0446\u0432\u0435\u0442 *\/ static void _texture_fill(int t, int x, int y, int source, int target) {     if ((x &gt;= TEXTURE_WIDTH || y &gt;= TEXTURE_HEIGHT ||           x &lt; 0 || y &lt; 0) ||           (textures[t][y][x] == target) ||           (textures[t][y][x] != source))         return;     textures[t][y][x] = target;     _texture_fill(t, x - 1, y, source, target);     _texture_fill(t, x + 1, y, source, target);     _texture_fill(t, x, y - 1, source, target);     _texture_fill(t, x, y + 1, source, target); }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u0438\u0437\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043b\u0438\u043d\u0438\u044e \u043f\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e SE  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] c \u0414\u043b\u0438\u043d\u0430 \u043b\u0438\u043d\u0438\u0438 \u043f\u043e \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435  * \\param[in] color \u0426\u0432\u0435\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f *\/ static void _texture_linese(int t, int x, int y, int c, int color) {     while (c--) {         textures[t][y][x++] = color;         textures[t][y++][x++] = color;     } }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u0438\u0437\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043b\u0438\u043d\u0438\u044e \u043f\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e SW  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] c \u0414\u043b\u0438\u043d\u0430 \u043b\u0438\u043d\u0438\u0438 \u043f\u043e \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435  * \\param[in] color \u0426\u0432\u0435\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f *\/ static void _texture_linesw(int t, int x, int y, int c, int color) {     while (c--) {         textures[t][y][x--] = color;         textures[t][y++][x--] = color;     } }  \/*! \\brief \u0420\u0438\u0441\u0443\u0435\u0442 \u043b\u0438\u043d\u0438\u044e \u0432\u043d\u0438\u0437  * \\param[in] t \u0418\u043d\u0434\u0435\u043a\u0441 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b  * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043d\u0430\u0447\u0430\u043b\u0430  * \\param[in] c \u0414\u043b\u0438\u043d\u0430 \u043b\u0438\u043d\u0438\u0438  * \\param[in] color \u0426\u0432\u0435\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f *\/ static void _texture_linedown(int t, int x, int y, int c, int color) {     while (c--)         textures[t][y++][x] = color; }  \/*! \\brief \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u0432\u0441\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b, \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 *\/ static void _textures_create(void) {     for (int tex = 0; tex &lt; TEXTURE_COUNT; tex++) {         const char * ptr = vecdata[tex];         int c = 0;         while (*ptr != TEXVEC_EXIT) {             switch (*ptr) {             case TEXVEC_LINESE:                 _texture_linese(tex, ptr[1], ptr[2], ptr[3], c);                 ptr += 4;                 break;                              case TEXVEC_LINESW:                 _texture_linesw(tex, ptr[1], ptr[2], ptr[3], c);                 ptr += 4;                 break;                              case TEXVEC_LINEDW:                 _texture_linedown(tex, ptr[1], ptr[2], ptr[3], c);                 ptr += 4;                 break;                              case TEXVEC_FILL:                 _texture_fill(tex, ptr[1], ptr[2], 0, c);                 ptr += 3;                 break;                              case TEXVEC_REPEAT:                 ptr = vecdata[ptr[1]];                 break;                              case TEXVEC_COLOR:                 c = texturepalette[ptr[1]];                 ptr += 2;                 break;             }         }     } }  \/*! \\brief \u0427\u0438\u0442\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430 \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043a\u0430\u0440\u0442\u0443   * \\param[in] filename \u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430-\u0447\u0435\u0440\u0442\u0435\u0436\u0430 *\/ static void _map_read(const char * filename) {     int f = open(filename, 0);     read(f, mapdata, MAP_FILEDATA);     close(f); }  \/*! \\brief \u0417\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0432\u0445\u043e\u0434\u044b \u0438\u0437 \u0444\u0430\u0439\u043b\u0430-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0432\u0445\u043e\u0434  * \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0430 \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0440\u043e\u043d\u0442\u0430 \u0432\u043e\u043b\u043d\u044b *\/ static void _map_wire_inputs(void) {     for (int y = 0; y &lt; MAP_HEIGHT; y++)         for (int x = 0; x &lt; MAP_WIDTH; x++)             if ((x % 14 == 2) &amp;&amp; (y % 4 == 3))                 mapdata[y][x] = MAPCHAR_WIRE; }  \/*! \\brief \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0437\u0430\u043b\u0438\u0432\u043a\u0443 \u043f\u0440\u043e\u0432\u043e\u0434\u043d\u0438\u043a\u0430 \u043d\u0443\u0436\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c  * \\param[in] t \u0418\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442 \u0430\u0432\u0442\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430   * \\param[in] x X-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0437\u0430\u043b\u0438\u0432\u043a\u0438  * \\param[in] y Y-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u0437\u0430\u043b\u0438\u0432\u043a\u0438  * \\param[in] c \u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435  * \\param[in] l \u0426\u0435\u043b\u0435\u0432\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 *\/ static void _map_fill(int t, int x, int y, int c, int l) {     if ((x &gt;= MAP_WIDTH || y &gt;= MAP_HEIGHT ||           x &lt; 0 || y &lt; 0) || (mapdata[y][x] == l)         || (mapdata[y][x] != c))         return;     mapdata[y][x] = l;     _map_fill(t, x - 1, y, c, l);     _map_fill(t, x + 1, y, c, l);     _map_fill(t, x, y - 1, c, l);     _map_fill(t, x, y + 1, c, l); }  \/*! \\brief \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432\u0445\u043e\u0434\u044b \u0441\u0445\u0435\u043c\u044b \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f  * \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430.  * \\param[in] counter \u0421\u0447\u0435\u0442\u0447\u0438\u043a *\/ static void _map_wire_counter(int counter) {     _map_fill(0, 2, 3,  mapdata[3][2],  counter &amp; 1 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 7,  mapdata[7][2],  counter &amp; 2 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 11, mapdata[11][2], counter &amp; 4 ? MAPCHAR_PLUS : MAPCHAR_MINUS);     _map_fill(0, 2, 15, mapdata[15][2], counter &amp; 8 ? MAPCHAR_PLUS : MAPCHAR_MINUS); }  \/*! \\brief \u041f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u0440\u0430\u0441\u0447\u0435\u0442 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e (\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e) \u0442\u043e\u043a\u0430 \u043f\u043e\u0441\u043b\u0435 NOR-\u0443\u0437\u043b\u0430 *\/ static void _map_process_gates(void) {            for (int i = 0; i &lt; MAP_ITERATIONS; i++)         for (int y = 0; y &lt; MAP_HEIGHT; y++)             for (int x = 0; x &lt; MAP_WIDTH; x++)                 if (mapdata[y][x] == MAPCHAR_NOR)                     _map_fill(0, x + 1, y, mapdata[y][x + 1],                         !(mapdata[y - 1][x] == MAPCHAR_PLUS ? 1 : 0                        || mapdata[y + 1][x] == MAPCHAR_PLUS ? 1 : 0) ?                              MAPCHAR_PLUS : MAPCHAR_MINUS); }  int main(int argc, char * args[]) {     _image_create();     _textures_create();          unsigned int counter = 1;     while (counter++) {         _map_read(args[ARG_BLUEPRINT]);         _map_wire_inputs();         _map_wire_counter(counter);         _map_process_gates();                  _image_reset();                   _image_compile();         _image_drill();         _image_postprocess();                 _image_draw();                  sleep(1);     }      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<h2>\u042d\u043f\u0438\u043b\u043e\u0433<\/h2>\n<p>  <a href=\"https:\/\/github.com\/codemeow\/ioccc2020\/blob\/master\/nor\/refactored.c\" rel=\"nofollow\">\u0412\u043e\u0442 \u0438 \u0432\u0441\u0451.<\/a> \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u044f \u043d\u0435 \u0437\u0430\u043d\u044f\u043b \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u0438\u0437\u043e\u0432\u044b\u0445 \u043c\u0435\u0441\u0442, \u044d\u0442\u043e \u0431\u044b\u043b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0439 \u043e\u043f\u044b\u0442 (\u0443\u043c\u0435\u0440\u0448\u0438\u0439 \u0437\u0430 \u0434\u0432\u0430 \u0434\u043d\u044f \u0434\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0438\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442 HDD \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u0441\u0442\u0432\u043e\u0432\u0430\u043b). \u0411\u044b\u043b\u043e \u0447\u0442\u043e-\u0442\u043e \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043d\u0435 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0439 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u044f\u0437\u044b\u043a\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u043d\u0435\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e. \u041a\u043e\u0433\u0434\u0430 \u0443\u0442\u0438\u043b\u0438\u0442\u0430, \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0442\u043e\u043a\u0435\u043d\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u043a\u043e\u0434 \u043d\u0430\u0440\u0443\u0448\u0430\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u044f \u043b\u0438\u043c\u0438\u0442 \u043d\u0430 2000+ \u0442\u043e\u043a\u0435\u043d\u043e\u0432, \u0430 \u0442\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u0448\u044c, \u043a\u0430\u043a \u0435\u0433\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u2014 \u044d\u0442\u043e \u0432\u044b\u0437\u043e\u0432. \u041a\u043e\u0433\u0434\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u043b\u0438\u043c\u0438\u0442\u044b, \u0430 \u0442\u044b \u0445\u043e\u0447\u0435\u0448\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 \u2014 \u044d\u0442\u043e \u0432\u044b\u0437\u043e\u0432. \u042d\u0442\u043e \u0431\u044b\u043b\u043e \u0442\u0440\u0443\u0434\u043d\u043e, \u0432\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430, \u0438 \u0442\u0435\u043c \u0441\u043b\u0430\u0449\u0435 \u0431\u044b\u043b\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u0443\u0442\u0438\u043b\u0438\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u043e\u0442\u0435\u043d \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u0430\u043a\u0438 \u0441\u043a\u0430\u0437\u0430\u043b\u0430, \u0447\u0442\u043e \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0442\u044c. \u042f \u0431\u044b \u043f\u043e\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f\u043c \u043f\u043e\u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u043a\u0443\u0440\u0441\u0435 \u0445\u043e\u0442\u044f \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043e\u0431\u0449\u0438\u0442\u044c\u0441\u044f \u0438 \u0438\u0441\u043f\u044b\u0442\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u0438\u043b\u044b. \u0414\u0430, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043d\u0430\u0433\u0440\u0430\u0434 \u0438\u043b\u0438 \u043f\u0440\u0438\u0437\u043e\u0432 \u044d\u0442\u043e \u043d\u0435 \u0434\u0430\u0435\u0442, \u043d\u043e \u0437\u0430\u0442\u043e \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u0434 \u043d\u0438\u043a\u043e\u043c zhestokyshveller \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 IOCCC \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0435\u0441\u044c \u0432\u044b.<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/516296\/\"> https:\/\/habr.com\/ru\/post\/516296\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/516296\/\">\u042d\u0442\u043e \u0432\u0442\u043e\u0440\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0446\u0438\u043a\u043b\u0430 \u0441\u0442\u0430\u0442\u0435\u0439 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u044f \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0432 IOCCC&#8217;19<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/bi\/qj\/io\/biqjioey5bqopnw4dtnlmvc2skw.png\"><\/p>\n<ol>\n<li><a href=\"https:\/\/habr.com\/ru\/post\/505044\/\">\u041a\u0430\u043a \u044f \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0432 IOCCC-&#8217;19 (\u0438 \u043f\u0440\u043e\u0438\u0433\u0440\u0430\u043b). \u0427\u0430\u0441\u0442\u044c 1: \u00ab\u041a\u0440\u0435\u0441\u0442\u0438\u043a\u0438-\u043d\u043e\u043b\u0438\u043a\u0438\u00bb<\/a><\/li>\n<li><a href=\"#\">\u041a\u0430\u043a \u044f \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0432 IOCCC-&#8217;19 (\u0438 \u043f\u0440\u043e\u0438\u0433\u0440\u0430\u043b). \u0427\u0430\u0441\u0442\u044c 2: \u00ab\u0421\u0438\u043c\u0443\u043b\u044f\u0442\u043e\u0440 NOR\u00bb<\/a><\/li>\n<\/ol>\n<p>  \u042f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u043f\u0440\u0438 \u0440\u0430\u0437\u0431\u043e\u0440\u0435 \u0447\u0443\u0436\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438\u043b\u0438 \u043a\u043e\u0434\u0430 \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u0438\u043b\u0438 \u043e\u0431\u0444\u0443\u0441\u043a\u0430\u0442\u043e\u0440\u0430.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0435 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 IOCCC \u0438\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<p>  \u0412\u0441\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u044f \u0436\u0435\u043b\u0430\u044e \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u044f.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-309185","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/309185","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=309185"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/309185\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=309185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=309185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=309185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}