Subversion Repositories Kolibri OS

Rev

Rev 969 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*      ------- ÊÎÑÈËÊÀ ÄËß ÊÎËÈÁÐÈ -------
  2. Èãðà ïèøåòñÿ íà C++ (èñïîëüçóåòñÿ MS Visual C++ 6.0).
  3. Ýòî - èñõîäíèê âåðñèè 1.0.
  4.  
  5.                                          Andrey Mihaylovich aka Dron2004
  6.   */
  7.  
  8.  
  9.  
  10. #include "kosSyst.h"
  11. #include "kosFile.h"
  12.  
  13.  
  14.  
  15. //ÂÍÅØÍÈÅ ÓÐÎÂÍÈ
  16. bool external_levels_available=false;
  17. bool external_levels = false;
  18. int level_read_result;
  19. Byte * externallevels;
  20. Byte external_levels_count[1] = {0};
  21. /////////////////
  22.  
  23. int lastkosilkadirection=1;
  24. int laststep=0; //Ïîñëåäíèé õîä. Çäåñü
  25.                                 // 0 - íåò òàêîâîãî
  26.                                 // 1 - âíèç
  27.                                 // 2 - ââåðõ
  28.                                 // 3 - âëåâî
  29.                                 // 4 - âïðàâî
  30.  
  31.  
  32. Byte skindata[13824];
  33. int read_result=0;
  34. bool skin_available=false;
  35. bool w_redraw=true;
  36.  
  37. const char windowTitle[]="Š®á¨«ª  ¤«ï Š®«¨¡à¨";
  38. const char version[]="‚¥àá¨ï 1.1";
  39. int levelcount=7; //×èñëî óðîâíåé
  40.  
  41. char gamearea[20][20]; //Êàðòà
  42.  
  43.  
  44. short int kosilkax; // Ïîëîæåíèå êîñèëêè
  45. short int kosilkay;
  46. short int kosilkadirection=1; //Íàïðàâëåíèå ïðîøëîãî øàãà. 1-âíèç, 2-ââåðõ, 3-âëåâî, 4-âïðàâî
  47. short int lives=2; // Æèçíè
  48. short int level=1; //Óðîâåíü
  49. short int status=0; //Ãäå 0 - ïðèâåòñòâèå
  50.                                         // 1 - èãðà
  51.                                         // 2 - èãðà ïðîéäåíà
  52.                                         // 3 - âû ïðîèãðàëè
  53.                                         // 4 - âûáîð íàáîðà óðîâíåé (âñòðîåííûé èëè âíåøíèé)
  54.                                         // -1 - î ïðîãðàììå
  55. bool gamestarted=false; //Áëîêèðîâêà èãðîâûõ êëàâèø. Åñëè false - èãðàòü íåëüçÿ
  56.  
  57. bool drawgraphics=true; //Ðèñîâàòü ëè äåòàëüíóþ ãðàôèêó (èëè îãðàíè÷èòüñÿ àñêåòè÷íîé)
  58. bool drawanimation=true; //Àíèìèðîâàòü ëè
  59. bool skinned=false;
  60. int grassLeft();  //Ñîîáùèì î íàëè÷èè ôóíêöèè Grass Left
  61.  
  62. //Ãðàôèêà èãðû
  63.  
  64. RGB kosilka_d[576];
  65. RGB kosilka_l[576];
  66. RGB kosilka_r[576];
  67. RGB kosilka_u[576];
  68. RGB grass[576];
  69. RGB stone[576];
  70. RGB tree[576];
  71. RGB skos[576];
  72.  
  73. Byte kosilka_d1[]={0,1,2,3,4,5,5,6,6,6,5,5,5,5,5,6,5,5,5,4,2,2,1,7,1,2,4,6,21
  74. ,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,6,5,2,40,1,4,62,63,63,64,65,66,66
  75. ,67,66,66,66,66,68,66,66,63,69,65,65,62,4,1,2,6,75,91,64,65,67,92,75,75,75,75,75
  76. ,75,75,75,75,93,65,94,94,62,6,2,3,6,76,94,96,67,103,104,104,104,104,104,104,105
  77. ,106,107,108,109,93,63,64,75,6,3,3,21,75,94,94,67,115,104,104,104,104,105,105
  78. ,106,107,108,116,117,92,65,96,76,21,4,3,21,62,64,63,78,115,105,105,105,105,106
  79. ,107,108,116,116,119,120,92,65,96,77,6,3,4,6,62,96,69,67,123,106,106,107,107,108
  80. ,108,116,119,119,127,124,92,66,64,77,21,4,3,21,62,64,91,67,123,107,108,108,116
  81. ,116,119,119,127,127,127,124,75,69,64,77,21,4,4,6,62,64,69,68,123,108,116,119
  82. ,119,127,127,127,129,129,129,125,93,63,64,77,21,4,4,21,62,64,91,67,123,119,119
  83. ,127,127,129,129,129,129,129,129,125,68,94,64,77,6,4,3,21,62,64,94,63,122,128
  84. ,128,121,121,121,121,121,121,121,121,76,66,69,91,77,21,4,4,21,62,64,94,69,69,65
  85. ,66,67,68,68,67,68,67,67,66,66,69,91,64,77,21,4,4,21,76,96,64,94,94,64,94,96,69
  86. ,91,94,94,64,69,69,94,64,64,64,77,6,4,3,6,75,64,64,64,64,64,64,64,64,64,64,64,64
  87. ,64,64,64,64,64,96,75,21,4,3,6,16,94,64,64,64,64,64,64,64,64,64,64,64,64,64,64
  88. ,64,64,96,75,6,2,2,6,75,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,62
  89. ,6,2,1,2,33,95,111,111,111,111,79,79,79,79,79,79,79,79,111,95,79,111,95,33,32,40
  90. ,7,42,49,44,47,72,44,47,80,49,45,72,45,70,47,47,47,46,71,45,44,49,50,15,15,43,45
  91. ,72,70,71,44,71,43,44,44,46,47,71,49,71,45,47,45,47,80,80,110,0,15,45,45,45,44
  92. ,44,72,72,70,45,44,71,46,71,80,44,45,47,44,71,72,71,45,9,14,45,47,72,46,73,45,47
  93. ,72,46,45,47,45,70,43,45,45,46,47,44,43,43,42,10,8,32,42,45,46,44,43,44,44,47,45
  94. ,45,49,44,46,46,45,44,45,44,45,42,41,9,10,114,36,36,12,10,12,14,9,11,10,36,13,11
  95. ,10,9,13,12,11,9,10,8,8,8
  96. };
  97.  
  98. Byte kosilka_u1[]={8,9,9,10,9,11,12,13,9,10,11,13,8,10,11,9,14,12,10,12,14,8,11
  99. ,10,9,41,42,43,44,45,44,45,46,46,44,45,45,45,47,44,44,43,44,46,45,42,32,0,14,42
  100. ,45,43,44,47,46,45,45,43,70,45,71,45,46,72,47,45,73,46,44,71,45,14,11,45,71,72
  101. ,71,44,47,45,44,80,71,46,71,44,45,70,72,72,44,44,45,45,45,15,0,110,80,80,71,45
  102. ,47,45,71,49,71,47,46,44,44,43,71,44,71,70,72,43,71,15,15,50,49,44,45,71,46,47
  103. ,47,71,70,45,72,45,49,80,47,44,72,47,44,45,50,15,1,32,121,95,111,79,95,111,79,79
  104. ,79,79,79,79,79,79,111,111,111,111,95,121,3,1,2,5,62,96,64,64,64,64,64,64,64,64
  105. ,64,64,64,64,64,64,64,96,96,75,5,2,2,6,75,94,64,64,64,64,64,64,64,64,64,64,64,64
  106. ,64,64,64,64,96,76,6,3,4,21,75,96,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64
  107. ,64,94,76,6,3,4,21,77,64,64,64,94,69,69,64,94,94,91,69,64,94,64,94,94,64,64,16
  108. ,21,4,4,6,77,64,91,69,66,66,66,67,67,67,68,68,67,66,65,69,69,94,64,77,21,4
  109. ,4,21,77,64,69,66,76,121,121,121,121,121,121,121,121,128,128,122,63,94,64,62,21
  110. ,3,4,6,77,64,94,67,125,129,129,129,129,129,129,127,127,119,119,123,66,91,64,62
  111. ,21,4,4,21,77,64,63,92,125,129,129,129,127,127,127,119,119,116,108,123,68,69,64
  112. ,62,6,4,4,21,77,64,63,92,124,127,127,127,119,119,116,108,108,108,108,123,68,91
  113. ,64,62,21,3,4,21,77,91,66,92,124,127,119,119,116,108,108,107,107,106,106,123,67
  114. ,69,64,62,21,3,3,21,77,64,65,92,120,119,116,116,108,107,106,105,105,105,105,115
  115. ,93,63,64,62,6,3,4,21,75,64,65,92,117,116,108,107,106,105,105,105,104,104,104
  116. ,115,67,94,96,76,21,3,3,6,75,96,63,93,109,108,107,106,105,104,104,104,104,104
  117. ,104,136,67,96,94,76,6,3,2,6,62,94,94,65,93,75,75,75,75,75,75,75,92,75,93,67,65
  118. ,64,64,75,6,2,1,4,62,65,65,69,63,65,66,67,66,66,65,65,67,66,66,65,64,63,65,62,4
  119. ,1,1,2,6,6,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,6,4,2,1,7,1,2,2,4,5
  120. ,5,6,6,5,5,5,6,6,6,6,6,5,6,3,4,2,1,0
  121. };
  122.  
  123. Byte kosilka_l1[]={10,8,14,15,15,15,1,2,3,2,4,4,3,3,4,3,3,3,3,3,2,1,1,0,11,48,49
  124. ,45,47,50,3,6,6,6,21,21,21,21,6,21,21,6,21,6,5,4,2,1,29,42,71,45,74,49,33,75,76
  125. ,76,76,62,62,62,62,62,62,62,76,76,75,62,4,2,14,70,72,45,72,44,95,96,94,94,94,96
  126. ,64,64,64,64,64,96,94,94,94,66,6,3,12,46,46,44,70,47,111,64,96,96,64,94,94,91,69
  127. ,91,69,63,94,96,64,63,21,4,10,44,73,44,71,72,111,64,64,64,94,69,63,66,68,67,67
  128. ,68,67,67,65,64,21,5,12,43,45,72,44,44,111,64,64,64,94,69,122,123,123,123,123
  129. ,115,115,103,67,63,21,6,14,44,47,72,71,47,111,64,64,64,64,65,128,119,116,107,106
  130. ,105,104,104,93,66,21,6,9,44,72,70,43,80,79,64,64,64,94,66,128,119,116,108,106
  131. ,105,104,104,75,66,21,6,11,47,46,45,44,49,79,64,64,64,64,67,121,127,116,108,107
  132. ,105,104,104,92,67,21,6,10,45,45,44,44,45,79,64,64,64,69,68,121,127,119,116,107
  133. ,106,104,104,75,66,21,6,8,49,47,71,46,72,79,64,64,64,91,68,121,129,127,116,108
  134. ,106,105,104,75,66,21,6,13,45,45,46,47,45,79,64,64,64,94,67,121,129,127,119,108
  135. ,107,105,104,75,66,21,4,11,44,70,71,71,70,79,64,64,64,94,67,121,129,127,119,116
  136. ,108,106,105,75,66,21,5,10,46,43,80,49,47,79,64,64,64,64,67,121,129,129,127,119
  137. ,108,107,106,75,67,21,4,9,46,45,44,71,47,79,64,64,64,69,67,121,129,129,127,119
  138. ,116,108,107,75,66,21,6,13,45,45,45,45,47,111,64,64,64,69,66,121,129,129,127,127
  139. ,119,116,108,75,66,21,6,12,44,46,47,47,46,95,64,64,64,94,66,76,125,125,124,124
  140. ,120,117,109,93,63,21,4,11,45,47,44,45,71,79,64,64,64,64,69,66,68,92,75,92,92,92
  141. ,93,65,69,21,6,9,44,44,71,47,45,111,64,64,64,64,91,69,94,63,69,66,65,65,63,94,65
  142. ,21,4,10,47,43,72,80,44,95,64,64,64,64,64,64,64,64,64,64,64,64,64,64,63,6,2,9,42
  143. ,45,47,80,45,121,62,75,75,77,77,77,77,77,77,77,77,75,75,62,75,5,2,0,48,42,45,71
  144. ,50,2,6,6,21,6,21,21,6,21,21,21,21,21,6,6,4,2,40,8,11,51,9,8,15,1,2,2,4,4,3,4,4
  145. ,4,4,4,3,3,3,2,1,1,7
  146. };
  147.  
  148. Byte kosilka_r1[]={7,1,1,2,3,3,3,4,4,4,4,4,4,4,4,2,2,1,15,0,9,12,9,8,40,2,4,6,6
  149. ,21,21,21,21,21,6,21,21,6,4,1,15,51,52,53,47,45,23,9,2,6,62,62,75,75,77,77,77,77
  150. ,77,77,77,77,77,77,78,79,45,80,47,71,42,9,2,6,65,94,94,94,96,64,64,64,64,64,64
  151. ,96,64,64,64,95,44,72,44,43,45,10,4,21,65,94,63,65,65,66,69,63,94,69,91,64,64,64
  152. ,64,79,43,47,71,44,72,9,5,21,69,65,93,92,92,92,92,92,67,66,69,64,64,64,64,79,71
  153. ,45,44,47,43,11,5,21,63,93,109,117,120,124,124,125,125,76,66,94,64,64,64,95,46
  154. ,47,47,46,72,12,6,21,65,75,108,116,119,127,127,129,129,121,66,69,64,64,64,111,47
  155. ,45,45,45,45,13,6,21,66,75,107,108,116,119,127,129,129,121,66,69,64,64,64,79,47
  156. ,71,44,45,44,9,4,21,67,75,106,107,116,119,127,129,129,121,67,64,64,64,64,79,47
  157. ,49,80,43,44,10,5,21,66,75,105,106,108,116,119,127,129,121,67,94,64,64,64,79,70
  158. ,71,71,70,72,11,4,21,66,75,104,105,107,108,119,127,129,121,67,94,64,64,64,79,45
  159. ,47,46,45,45,13,6,21,66,75,104,105,106,108,116,127,129,121,68,91,64,64,64,79,72
  160. ,46,71,47,45,8,6,21,65,75,104,104,105,107,116,119,127,121,68,69,64,64,64,79,45
  161. ,44,44,45,45,10,6,21,67,75,104,104,105,107,108,116,127,121,67,64,64,64,64,79,49
  162. ,44,45,46,46,11,6,21,66,92,104,104,105,106,108,116,119,128,66,94,64,64,64,79,80
  163. ,43,70,72,72,9,6,21,66,92,104,104,105,106,107,108,119,128,65,64,64,64,64,111,47
  164. ,71,72,47,72,14,6,21,65,67,103,115,115,123,123,123,123,122,69,94,64,64,64,111,44
  165. ,44,72,45,47,12,5,21,64,65,67,67,93,68,68,93,66,63,69,94,64,64,64,111,72,71,44
  166. ,73,72,10,3,21,63,64,96,94,63,69,91,69,91,94,94,64,64,64,64,111,47,70,44,46,44
  167. ,12,4,6,63,64,64,64,64,64,64,64,64,64,64,64,64,64,64,95,44,72,45,72,45,14,2,4,62
  168. ,75,76,76,62,62,62,62,62,62,62,76,62,62,77,79,45,43,45,46,42,36,1,2,5,6,6,21,6
  169. ,21,21,6,21,21,21,21,6,6,6,37,52,46,45,45,20,11,0,40,40,2,3,4,4,3,3,4,4,2,4,4,3
  170. ,3,2,1,15,15,15,14,36,10
  171. };
  172.  
  173. Byte skos1[]={13,14,14,14,12,11,10,14,11,14,10,9,13,13,13,14,9,13,8,12,13,11,14
  174. ,8,11,10,9,8,10,10,12,11,14,10,9,14,14,9,10,12,10,14,9,11,10,8,10,8,13,14,10,8
  175. ,10,10,13,13,10,11,11,10,8,14,12,13,9,12,12,12,9,9,9,12,8,13,9,13,8,14,13,8,12
  176. ,13,11,9,11,14,9,10,10,9,14,10,8,12,12,13,9,10,14,12,14,12,9,9,8,8,10,8,12,8,14
  177. ,13,13,14,8,10,9,10,10,9,13,9,8,9,8,12,12,9,14,14,10,14,14,14,14,9,12,14,12,14
  178. ,13,10,11,51,12,13,10,14,8,8,11,13,8,8,8,9,14,12,8,13,14,14,9,14,13,9,8,126
  179. ,12,8,10,11,10,8,14,14,10,8,12,12,13,12,9,13,10,14,13,11,12,9,11,12,13,13,11,13
  180. ,12,13,13,10,8,10,14,12,11,10,11,9,14,10,11,11,11,12,9,8,9,13,14,8,8,14,10,11,9
  181. ,14,13,9,10,11,12,8,11,8,8,13,9,12,9,10,10,11,12,8,10,11,9,9,10,10,14,14,8,14,8
  182. ,13,14,9,14,11,8,12,12,14,12,14,13,9,11,8,8,14,10,9,11,12,11,10,9,9,9,11,11,14
  183. ,10,11,14,11,9,8,12,12,9,14,14,10,14,14,14,14,9,12,14,12,14,13,10,11,10,10,10,10
  184. ,8,8,8,10,13,9,12,9,12,8,8,14,11,11,13,13,12,13,12,8,11,12,13,11,12,10,13,8,8,8
  185. ,10,9,11,13,14,12,14,12,12,12,8,14,12,13,10,10,8,14,11,13,14,11,9,10,12,13,8,10
  186. ,11,13,11,11,14,9,11,8,10,14,10,14,10,12,8,8,14,14,11,13,11,12,8,8,13,12,11,14,9
  187. ,13,11,8,12,10,10,8,12,12,51,10,9,8,9,13,10,14,8,14,8,9,9,14,8,10,14,13,8,11,8
  188. ,11,13,12,13,10,13,10,10,10,9,12,11,13,14,13,11,8,14,8,10,10,10,14,13,10,11,10
  189. ,11,13,13,12,12,9,11,12,8,13,9,10,14,10,9,9,9,13,12,12,11,8,13,13,36,13,9,10,13
  190. ,12,8,13,12,9,13,10,11,12,12,10,9,13,8,9,12,10,11,12,14,9,14,14,8,11,14,12,12,10
  191. ,11,9,8,8,14,14,11,13,11,12,8,8,13,12,8,8,10,13,14,10,11,8,8,8,11,11,14,11,12,10
  192. ,13,9,14,14,9,9,11,9,10,11,8,14,12,10,12,14,9,11,10,8,13,11,10,9,13,12,11,9,10,9
  193. ,9,8
  194. };
  195.  
  196. Byte grass1[]={16,17,17,18,17,19,20,21,22,22,23,22,24,18,23,23,25,18,22,26,27,28
  197. ,28,18,20,24,28,54,55,19,54,56,24,20,54,24,24,20,24,20,20,24,27,24,17,54,54,24
  198. ,55,55,28,55,55,54,54,55,54,24,54,54,24,24,54,20,54,17,54,54,55,24,81,55,17,19
  199. ,17,27,81,27,54,19,17,54,41,18,24,24,81,23,19,55,18,27,24,97,20,54,19,112,55,81
  200. ,18,24,19,24,48,20,55,28,81,28,18,24,112,55,18,81,17,54,24,54,118,19,54,81,23,81
  201. ,55,41,26,23,26,26,41,20,26,55,19,81,18,17,28,54,19,28,55,54,17,22,17,55,17,17
  202. ,81,18,28,25,97,18,27,112,112,81,24,24,27,26,81,54,24,54,17,27,55,28,23,97,25,54
  203. ,28,23,26,26,22,112,55,97,24,28,27,26,16,55,17,27,54,18,19,54,23,16,97,20,54,25
  204. ,26,26,19,19,48,18,16,28,17,23,20,19,28,55,24,20,19,28,20,48,23,33,19,97,26,26
  205. ,55,54,18,26,25,19,28,26,28,17,27,55,81,23,19,19,18,20,24,41,54,22,26,81,17,27
  206. ,17,25,26,28,24,48,22,27,26,55,54,55,55,28,16,33,5,24,41,18,48,55,19,48,97,16,26
  207. ,27,48,33,23,97,22,28,19,54,48,81,21,6,21,41,26,33,33,28,54,20,16,48,18,26,33,16
  208. ,48,23,17,19,112,26,23,48,21,21,131,48,26,33,97,17,17,20,16,25,97,16,16,26,21,20
  209. ,19,112,54,26,26,21,20,41,6,33,16,25,33,55,19,16,41,25,48,16,26,48,97,24,55,54
  210. ,24,24,23,21,23,97,48,21,33,24,6,54,54,132,54,18,16,97,28,26,22,28,27,54,20,16
  211. ,23,33,22,16,26,48,17,20,33,54,24,19,20,25,97,48,54,54,26,27,20,20,41,21,97,6,33
  212. ,23,26,48,19,17,48,24,23,24,27,16,18,16,55,55,19,26,27,54,48,21,24,48,23,33,25
  213. ,33,28,23,97,97,6,16,16,20,25,48,17,48,97,22,27,24,20,48,22,17,27,48,48,16,22,25
  214. ,24,41,33,25,25,54,23,97,17,18,27,22,97,24,20,18,23,27,17,23,48,25,23,97,27,97
  215. ,18,26,18,22,26,18,19,17,28,26,23,17,81,97,25,81,27,24,6,97,48,18,97,16,16,81,33
  216. ,18,22,26,24,17,27,23,26,17,27,23,26,26,54,41,33,18,97,22,18,22,48,18,16,97,22
  217. ,18,18,27,27,26,48,27,17,97,18,27,55,21,20,26,23,26,27,27,22,26,16,23,22,26,27
  218. ,140,19,20
  219. };
  220.  
  221. Byte stone1[]={13,14,14,29,30,31,31,31,30,3,32,33,32,34,35,36,9,13,8,12,13,11,14
  222. ,8,11,10,36,30,31,57,58,57,31,59,59,59,59,31,31,30,32,29,11,11,10,8,10,8,13,8,30
  223. ,31,58,82,83,82,82,83,84,84,85,84,83,58,59,30,30,51,9,9,9,12,8,98,30,57,99,83,83
  224. ,83,83,84,84,85,100,73,49,74,73,82,31,30,8,12,12,13,9,0,30,57,82,83,83,83,83,84
  225. ,84,85,85,73,49,74,113,74,84,59,30,114,10,9,12,0,30,59,58,82,83,83,83,83,84,85
  226. ,85,73,49,74,74,113,113,83,31,30,11,10,12,13,30,30,57,99,82,83,83,83,84,84,85
  227. ,100,49,49,74,113,113,74,99,30,29,13,12,8,0,30,57,82,83,83,83,83,83,84,85,100,73
  228. ,49,74,113,113,113,85,31,40,12,13,13,1,30,99,83,83,83,83,83,83,84,84,85,73,49,74
  229. ,74,113,113,74,57,32,8,9,13,30,59,82,83,82,83,83,83,83,83,84,85,100,73,49,74,74
  230. ,113,113,57,5,51,10,0,30,57,82,82,83,83,83,83,83,83,84,85,85,73,49,74,74,113,113
  231. ,58,130,11,12,29,30,57,82,82,83,83,83,83,83,83,83,84,85,100,73,49,74,74,74,99,30
  232. ,11,9,29,30,57,82,82,83,83,83,83,83,83,83,84,84,85,73,49,49,74,74,82,30,0,8,8,30
  233. ,31,99,82,82,83,83,83,83,83,83,83,84,85,100,73,49,74,74,83,31,15,12,10,15,30,58
  234. ,82,82,82,83,83,83,83,83,83,84,84,85,100,73,49,74,84,31,1,11,13,7,30,58,82,82,82
  235. ,82,82,82,83,83,82,83,84,85,85,100,73,49,84,31,15,8,8,7,30,58,82,82,82,82,82,82
  236. ,82,82,82,83,84,84,85,85,73,73,82,30,35,10,10,35,30,57,82,82,82,82,82,82,82,82
  237. ,83,82,83,84,84,85,85,85,59,30,51,13,10,133,30,59,99,99,82,82,82,82,82,82,82,83
  238. ,82,83,84,84,84,57,30,35,10,11,13,13,1,31,58,82,99,82,82,82,99,58,58,82,82,83,83
  239. ,99,57,31,40,13,13,8,13,9,0,30,59,99,99,99,99,99,58,59,59,57,57,57,59,31,30,15
  240. ,10,11,12,14,9,14,14,15,30,31,58,58,58,57,30,30,30,30,30,30,32,1,37,8,8,13,12,8
  241. ,8,10,13,14,35,30,30,31,30,30,30,8,0,37,0,133,9,14,14,9,9,11,9,10,11,8,14,12,10
  242. ,37,40,32,1,35,8,13,11,10,9,13,12,11,9,10,9,9,8
  243. };
  244.  
  245. Byte tree1[]={13,14,8,36,37,11,10,36,38,39,0,14,13,13,13,14,9,13,8,12,13,11,14,8
  246. ,11,36,39,39,39,34,38,39,60,61,60,39,34,0,37,37,14,36,15,36,14,8,10,8,11,86,60
  247. ,87,61,60,88,61,89,90,89,61,60,88,39,86,39,88,88,88,39,15,9,12,34,88,87,89,89
  248. ,101,89,89,89,89,89,89,101,61,61,90,89,89,102,87,60,39,37,13,34,60,89,89,89,89
  249. ,89,89,89,89,89,89,89,89,89,89,89,89,89,89,102,88,7,11,15,88,102,101,89,89,89,89
  250. ,89,89,101,89,89,101,89,89,89,89,89,89,101,60,34,51,8,39,60,102,89,89,89,89,89
  251. ,90,102,101,89,101,101,89,89,89,89,89,101,60,39,51,37,34,60,90,101,89,89,101,89
  252. ,101,101,89,89,89,89,89,89,89,89,89,89,87,88,15,37,60,89,89,89,89,101,90,89,89
  253. ,89,89,89,89,89,89,89,89,89,89,89,101,102,88,39,102,89,89,89,89,101,90,89,89,89
  254. ,89,89,89,101,101,101,101,89,89,89,89,89,61,32,102,89,89,89,89,101,90,90,101,89
  255. ,89,89,101,87,101,89,89,89,89,89,89,89,102,39,61,89,89,89,89,89,89,101,102,101
  256. ,89,89,90,89,89,89,89,89,89,89,89,89,90,9,39,61,101,89,89,89,89,101,102,102,89
  257. ,101,101,89,89,89,89,89,89,89,89,89,102,36,34,88,102,89,89,89,89,89,101,101,89
  258. ,89,89,89,89,89,89,89,89,89,101,90,60,8,39,60,101,89,89,89,89,89,89,89,89,89,89
  259. ,89,89,89,89,89,89,89,101,101,60,34,88,101,89,89,89,89,89,89,89,89,89,89,89,89
  260. ,89,89,89,89,101,101,89,89,102,34,60,89,89,89,89,89,89,89,89,89,89,89,89,89,89
  261. ,89,89,101,90,101,89,89,101,34,88,87,89,89,101,89,89,89,89,90,102,89,89,89,89,89
  262. ,89,89,89,101,89,89,102,37,32,60,102,87,87,89,89,89,134,135,135,101,89,89,89,89
  263. ,89,89,89,101,102,102,60,11,51,37,38,34,88,61,102,61,39,137,131,134,101,101,101
  264. ,102,90,89,89,102,60,39,37,8,51,11,37,37,0,39,39,32,15,137,137,138,60,61,60,88
  265. ,88,102,102,60,39,40,10,11,9,14,8,8,36,40,36,51,51,137,137,137,34,39,34,29,38,39
  266. ,39,32,15,13,12,8,8,10,51,14,37,37,8,8,8,137,137,137,8,9,139,51,8,7,7,14,11,11,9
  267. ,10,11,8,14,51,10,12,14,11,11,137,137,137,11,10,9,13,51,14,11,51,9,9,8
  268. };
  269.  
  270.  
  271. //Ïàëèòðà öâåòîâ. Äåêîäèðóåì â 0xRRGGBB
  272.  
  273. char * apppath;
  274. char * levpath;
  275. char * getSkinPathName(){
  276.  
  277.         int lastslashindex=0;
  278.         static char skinfilename[]="kosskin.gfx";
  279.         int tempslfnd=0;
  280.  
  281.         for (tempslfnd=0; tempslfnd < strlen(kosExePath); tempslfnd++){
  282.                         if (kosExePath[tempslfnd]=='/'){lastslashindex=tempslfnd;}
  283.         }
  284.  
  285.         apppath = new char[lastslashindex+strlen(skinfilename)+1];
  286.  
  287.         for (tempslfnd=0; tempslfnd <= lastslashindex; tempslfnd++){
  288.                 apppath[tempslfnd]=kosExePath[tempslfnd];
  289.         }
  290.         for (tempslfnd=0; tempslfnd < strlen(skinfilename); tempslfnd++){
  291.                 apppath[tempslfnd+lastslashindex+1]=skinfilename[tempslfnd];
  292.         }
  293.        
  294.  
  295.         return apppath;
  296.        
  297.  
  298. }
  299.  
  300. char * getLevelsPathName(){
  301.  
  302.         int lastslashindex=0;
  303.         static char levfilename[]="koslevel.pak";
  304.         int tempslfnd=0;
  305.  
  306.         for (tempslfnd=0; tempslfnd < strlen(kosExePath); tempslfnd++){
  307.                         if (kosExePath[tempslfnd]=='/'){lastslashindex=tempslfnd;}
  308.         }
  309.  
  310.         levpath = new char[lastslashindex+strlen(levfilename)+1];
  311.  
  312.         for (tempslfnd=0; tempslfnd <= lastslashindex; tempslfnd++){
  313.                 levpath[tempslfnd]=kosExePath[tempslfnd];
  314.         }
  315.         for (tempslfnd=0; tempslfnd < strlen(levfilename); tempslfnd++){
  316.                 levpath[tempslfnd+lastslashindex+1]=levfilename[tempslfnd];
  317.         }
  318.  
  319.         return levpath;
  320.                
  321.  
  322. }
  323.  
  324.  
  325. void decode_graphics(Byte * source, RGB * target){
  326.         static RGB palette[] = {
  327.                 0x978A31,0x8B7F2E,0x867B2B,0x82762B,0x7F7428,0x79702B,0x766C26,0x90832E,
  328.                 0x978A2F,0x9A8C31,0x9B8D32,0x998C31,0x9C8E33,0x9D8F34,0x988B30,0x928531,
  329.                 0x887532,0xBAA454,0xA18C3D,0xC6B26A,0xA08E46,0x6B5F26,0xAF9844,0x9C873B,
  330.                 0xAB964D,0x988338,0xA89140,0xB49D4C,0xC1AC5C,0x94872F,0x303030,0x343435,
  331.                 0x827933,0x806E2F,0x8B8134,0x938632,0x96892F,0x988C33,0x8F873B,0x7E9F39,
  332.                 0x8E812D,0x92803F,0x75715C,0x676462,0x6D6A68,0x666260,0x6B6866,0x6A6664,
  333.                 0x8E7B35,0x626161,0x797641,0x9B8E33,0x7F7954,0x776A67,0xB29E55,0xBCA75E,
  334.                 0x978C3E,0x3E3E3D,0x434245,0x373938,0x3C9737,0x209437,0xB97934,0xE6863E,
  335.                 0xF28C41,0xE2833D,0xDD803B,0xD77C3A,0xD17938,0xEA883F,0x605D5B,0x686563,
  336.                 0x706D6B,0x5F5F5E,0x656566,0xB56931,0xAC663B,0xC17D36,0xC88338,0x997246,
  337.                 0x737271,0xA89546,0x4D4D4E,0x515152,0x565656,0x5A5A59,0x687B41,0x098933,
  338.                 0x5B9B38,0x009036,0x069136,0xF18B41,0xC27034,0xCD7737,0xEE8A40,0xA0774B,
  339.                 0xF18C41,0x948037,0x988B34,0x49484A,0x5D5D5D,0x039036,0x0E9236,0xB06B7B,
  340.                 0x949CF8,0x7C85F6,0x6A74F5,0x5A66F4,0x4653F1,0x5F53B6,0x726462,0x9C7449,
  341.                 0xD0C472,0x696969,0x998B32,0x9D6676,0x3B47DD,0x5349A0,0xD8CD77,0x343EC1,
  342.                 0x4F438C,0x8E5538,0xC37341,0x895D71,0x483B74,0x433359,0x9C8D34,0x2A329A,
  343.                 0x995F49,0x1D236D,0x756E37,0x524819,0x8D8848,0x9B8D34,0x157F2F,0x2D6C28,
  344.                 0xAA778B,0x663C15,0x4E5924,0x9D8F31,0xBCAD48
  345.         };
  346.  
  347.         for (int lc=0;lc<576;lc++)
  348.                 target[lc] = palette[source[lc]];
  349. }
  350.  
  351.  
  352. void interlevelpause(){ //Ïàóçà ìåæäó óðîâíÿìè
  353.         Byte tempCode;
  354.         RGB tmprgb;
  355.         int tmpa=0;
  356.         laststep=0;
  357.         static int yellow_pal[] = {0xA8A93D,0xBEBF4C,0xD6D856,0xDFE15A,0xECEE5B,
  358.                                                     0xECEE5B,0xDFE15A,0xD6D856,0xBEBF4C,0xA8A93D};
  359.                 for (int iic=0;iic<240;iic++){
  360.                         kos_WaitForEvent(1);
  361.                         kos_GetKey(tempCode);
  362.  
  363.                         kos_DrawBar(iic*2,0,2,480,yellow_pal[tmpa]);
  364.  
  365.                         tmpa++;
  366.                         if (tmpa>9){tmpa=0;}
  367.                 }
  368. }
  369.  
  370. void draw_element(int elx, int ely){ //Îòðèñîâêà ýëåìåíòà êàðòû
  371. switch (gamearea[elx][ely]){
  372.                         case 'g':
  373.                                 if (drawgraphics==true){
  374.                                         kos_PutImage((RGB*)grass,24,24,elx*24,ely*24);
  375.                                 }
  376.                                 else
  377.                                 {
  378.                                         kos_DrawBar(elx*24,ely*24,24,24,0xAAAA00);
  379.                                 }
  380.                        
  381.                                 break;
  382.                         case 'k':
  383.                                 if (drawgraphics==true){
  384.                                         switch(kosilkadirection){
  385.                                         case 1:
  386.                                                 kos_PutImage((RGB*)kosilka_d,24,24,elx*24,ely*24);
  387.                                                 break;
  388.                                         case 2:
  389.                                                 kos_PutImage((RGB*)kosilka_u,24,24,elx*24,ely*24);
  390.                                                 break;
  391.                                         case 3:
  392.                                                 kos_PutImage((RGB*)kosilka_l,24,24,elx*24,ely*24);
  393.                                                 break;
  394.                                         case 4:
  395.                                                 kos_PutImage((RGB*)kosilka_r,24,24,elx*24,ely*24);
  396.                                                 break;
  397.                                         }
  398.  
  399.  
  400.                                 }
  401.                                 else
  402.                                 {
  403.                                         kos_DrawBar(elx*24,ely*24,24,24,0x00AAAA);
  404.                                 }
  405.  
  406.                
  407.  
  408.                                 break;
  409.                         case 'n':
  410.                                 if (drawgraphics==true){
  411.                                         kos_PutImage((RGB*)skos,24,24,elx*24,ely*24);
  412.                                 }
  413.                                 else
  414.                                 {
  415.                                         kos_DrawBar(elx*24,ely*24,24,24,0xAAAAAA);
  416.                                 }
  417.  
  418.  
  419.                                 break;
  420.                         case 's':
  421.                                 if (drawgraphics==true){
  422.                                         kos_PutImage((RGB*)stone,24,24,elx*24,ely*24);
  423.                                 }
  424.                                 else
  425.                                 {
  426.                                         kos_DrawBar(elx*24,ely*24,24,24,0x555555);
  427.                                 }
  428.  
  429.  
  430.                                 break;
  431.  
  432.                         case 't':
  433.                                 if (drawgraphics==true){
  434.                                         kos_PutImage((RGB*)tree,24,24,elx*24,ely*24);
  435.                                 }
  436.                                 else
  437.                                 {
  438.                                         kos_DrawBar(elx*24,ely*24,24,24,0x005500);
  439.                                 }
  440.  
  441.  
  442.                                 break;
  443.  
  444.                         }
  445.  
  446. }
  447.  
  448.  
  449. void display_grass_left(){ //Âûâîäèì íà ýêðàí êîëè÷åñòâî îñòàâøåéñÿ òðàâû
  450.         kos_DrawBar(605,120,20,10,0xEEEEEE);
  451.         kos_DisplayNumberToWindow(grassLeft(),3,605,120,0x0000FF,nbDecimal,false);
  452. }
  453.  
  454.  
  455. void animate(int initcellx, int initcelly, int direction){ //àíèìàöèÿ äâèæåíèÿ êîñèëêè
  456.         int tmpp=0;
  457.        
  458.                 switch (direction){
  459.                 case 1:
  460.                         for (tmpp=0; tmpp<23;tmpp++){
  461.                                 if (drawgraphics==true){
  462.                                         kos_PutImage((RGB*)skos,24,24,initcellx*24,initcelly*24);
  463.                                         kos_PutImage((RGB*)kosilka_d,24,24,initcellx*24,initcelly*24+tmpp);
  464.                                 } else {
  465.                                         kos_DrawBar(initcellx*24,initcelly*24,24,24,0xAAAAAA);
  466.                                         kos_DrawBar(initcellx*24,initcelly*24+tmpp,24,24,0x00AAAA);
  467.  
  468.                                 }
  469.                                 kos_Pause(1);
  470.                         }
  471.                         break;
  472.                 case 2:
  473.                         for (tmpp=0; tmpp<23;tmpp++){
  474.                                 if (drawgraphics==true){
  475.                                         kos_PutImage((RGB*)skos,24,24,initcellx*24,initcelly*24);
  476.                                         kos_PutImage((RGB*)kosilka_u,24,24,initcellx*24,initcelly*24-tmpp);
  477.                                 } else {
  478.                                         kos_DrawBar(initcellx*24,initcelly*24,24,24,0xAAAAAA);
  479.                                         kos_DrawBar(initcellx*24,initcelly*24-tmpp,24,24,0x00AAAA);
  480.                                 }
  481.                                 kos_Pause(1);
  482.                         }
  483.                         break;
  484.                 case 3:
  485.                         for (tmpp=0; tmpp<23;tmpp++){
  486.                                 if (drawgraphics==true){
  487.                                         kos_PutImage((RGB*)skos,24,24,initcellx*24,initcelly*24);
  488.                                         kos_PutImage((RGB*)kosilka_r,24,24,initcellx*24+tmpp,initcelly*24);
  489.                                 } else {
  490.                                         kos_DrawBar(initcellx*24,initcelly*24,24,24,0xAAAAAA);
  491.                                         kos_DrawBar(initcellx*24+tmpp,initcelly*24,24,24,0x00AAAA);
  492.  
  493.                                 }
  494.                                 kos_Pause(1);
  495.                         }
  496.                         break;
  497.                 case 4:
  498.                         for (tmpp=0; tmpp<23;tmpp++){
  499.                                 if (drawgraphics==true){
  500.                                         kos_PutImage((RGB*)skos,24,24,initcellx*24,initcelly*24);
  501.                                         kos_PutImage((RGB*)kosilka_l,24,24,initcellx*24-tmpp,initcelly*24);
  502.                                 } else {
  503.                                         kos_DrawBar(initcellx*24,initcelly*24,24,24,0xAAAAAA);
  504.                                         kos_DrawBar(initcellx*24-tmpp,initcelly*24,24,24,0x00AAAA);
  505.  
  506.                                 }
  507.                                 kos_Pause(1);
  508.                         }
  509.                         break;
  510.                 }
  511.  
  512.        
  513. }
  514.  
  515.  
  516. void draw_window(void){ //Ïåðåðèñîâêà îêíà
  517.         //----Leency
  518.         if (w_redraw)
  519.         {
  520.                 kos_WindowRedrawStatus(1); //Íà÷àëî ïåðåðèñîâêè
  521.                 kos_DefineAndDrawWindow(50,50,640,506,0x74,0xEEEEEE,0,0,(Dword)windowTitle);
  522.         }
  523.         w_redraw=false;
  524.  
  525.  
  526.         //Ïåðåðèñîâêà êàðòû
  527.         if ((status!=0)&&(status!=-1)&&(status!=4))
  528.         {
  529.                 kos_DrawBar(631-151,0,151,480,0xEEEEEE);
  530.  
  531.                 kos_WriteTextToWindow(505,30,0x80, 0 ,"Š  Ž  ‘  ˆ  ‹  Š  €",19);
  532.                 kos_WriteTextToWindow(522,40,0x80, 0 ,"¤«ï Š®«¨¡à¨ Ž‘",14);
  533.  
  534.                 kos_WriteTextToWindow(495,80,0x80, 0 ,"“஢¥­ì:",6);
  535.                 kos_DisplayNumberToWindow(level,3,605,80,0x0000FF,nbDecimal,false);
  536.  
  537.                 kos_WriteTextToWindow(495,95,0x80, 0 ,"Žáâ «®áì ¯®¯ë⮪:",11);
  538.                 kos_DisplayNumberToWindow(lives,1,605,95,0x0000FF,nbDecimal,false);
  539.  
  540.                 kos_WriteTextToWindow(495,120,0x80, 0 ,"Žáâ «®áì âà ¢ë:",11);
  541.                 display_grass_left();
  542.  
  543.                 kos_WriteTextToWindow(526,450,0x80, 0 ,(char*)version,12);
  544.  
  545.                 for (int cy=0;cy<20;cy++) for (int cx=0;cx<20;cx++)     draw_element(cx,cy);
  546.         }
  547.  
  548.         if (status==0){
  549.                 kos_DrawBar(0,0,4,480,0x000000);
  550.                 kos_DrawBar(628,0,3,480,0x000000);
  551.                 //Leency----
  552.                
  553.  
  554.                 for (int tmpppy=0;tmpppy<20;tmpppy++){
  555.                         for (int tmpppx=0;tmpppx<26;tmpppx++){
  556.                                 if ((tmpppx==0) || (tmpppx==25) || (tmpppy==0) || (tmpppy==19)){
  557.                                         kos_PutImage((RGB*)stone,24,24,4+tmpppx*24,tmpppy*24);
  558.                                 }
  559.                                 else
  560.                                 {
  561.                                         kos_PutImage((RGB*)skos,24,24,4+tmpppx*24,tmpppy*24);
  562.                                 }
  563.                         }
  564.                 }
  565.  
  566.                 if (drawgraphics==true){
  567.                         kos_PutImage((RGB*)kosilka_d,24,24,305,150);
  568.                 }
  569.                 else
  570.                 {
  571.                         kos_DrawBar(305,150,24,24,0x00AAAA);
  572.                 }
  573.  
  574.  
  575.                 if (drawanimation==true){
  576.                         kos_DrawBar(335,150,24,24,0x00AA00);
  577.                 }
  578.                 else
  579.                 {
  580.                         kos_DrawBar(335,150,24,24,0xAA0000);
  581.                 }
  582.  
  583.                 kos_WriteTextToWindow(257,200,0x80, 0xFFFFFF ,"Š   Ž   ‘   ˆ   ‹   Š   €",19);
  584.                 kos_WriteTextToWindow(290, 220,0x80, 0xFFFFFF ,"¤«ï Š®«¨¡à¨ Ž‘",14);
  585.                 kos_WriteTextToWindow(239, 240,0x80, 0xFFFFFF ,"<¤«ï ­ ç «  ¨£àë ­ ¦¬¨â¥ ENTER>",30);
  586.                 kos_WriteTextToWindow(30, 380,0x80, 0xFFFFFF ,"<­ ¦¬¨â¥ <g> ¤«ï ¯¥à¥ª«î祭¨ï ०¨¬  £à ä¨ª¨>",53);
  587.                 kos_WriteTextToWindow(30, 400,0x80, 0xFFFFFF ,"<­ ¦¬¨â¥ <a> ¤«ï ¢ª«î祭¨ï/¢ëª«î祭¨ï  ­¨¬ æ¨¨>",41);
  588.                 kos_WriteTextToWindow(30, 420,0x80, 0xFFFFFF ,"<­ ¦¬¨â¥ <h> ¤«ï ¯à®á¬®âà  á¢¥¤¥­¨© ® ¯à®£à ¬¬¥>",32);
  589.                 if (skin_available==true) {kos_WriteTextToWindow(30, 440,0x80, 0xFFFFFF ,"<­ ¦¬¨â¥ <s> çâ®¡ë ¢ëª«îç¨âì/¢ª«îç¨âì ᪨­>",27);}
  590.  
  591.  
  592.         //      kos_WriteTextToWindow(470, 440,0x80, 0xFFFFFF ,"­ ¦¬¨â¥ <ESC> ¤«ï ¢ë室 ",27);
  593.         //      kos_DisplayNumberToWindow(external_levels_count[0],3,200,340,0x0000FF,nbDecimal,false);
  594.  
  595.  
  596.  
  597.                 kos_WriteTextToWindow(536, 440,0x80, 0xFFFFFF ,(char*)version,0);
  598.         }
  599.         if (status==2){
  600.            kos_DrawBar(10,150,610,200,0x528B4C);       
  601.            kos_DrawBar(15,155,601,190,0x3BCF46);       
  602.            kos_WriteTextToWindow(240,230,0x80, 0xFFFFFF ,"‚ë ¢ë¨£à «¨!",13);
  603.            kos_WriteTextToWindow(240,250,0x80, 0xFFFFFF ,"<­ ¦¬¨â¥ q ¤«ï ¢®§¢à â  ¢ ¬¥­î>",17);
  604.         }
  605.         if (status==3){
  606.            kos_DrawBar(10,150,610,200,0x8B4C4C);       
  607.            kos_DrawBar(15,155,601,190,0xCF3B3B);       
  608.            kos_WriteTextToWindow(220,220,0x80, 0xFFFFFF ,"ˆ£à  ®ª®­ç¥­ ...",13);
  609.            kos_WriteTextToWindow(220,240,0x80, 0xFFFFFF ,"<­ ¦¬¨â¥ r ¤«ï ⮣®, ç⮡ë áë£à âì ¥éñ à §>",23);
  610.            kos_WriteTextToWindow(220,260,0x80, 0xFFFFFF ,"<­ ¦¬¨â¥ q ¤«ï ¢®§¢à â  ¢ ¬¥­î>",17);
  611.         }
  612.         if (status==-1){
  613.  
  614.                 kos_DrawBar(0,0,4,480,0x000000);
  615.                 kos_DrawBar(631-3,0,3,480,0x000000);
  616.  
  617.            for (int tmpppy=0;tmpppy<20;tmpppy++){
  618.                         for (int tmpppx=0;tmpppx<26;tmpppx++){
  619.                                 if ((tmpppx==0) || (tmpppx==25) || (tmpppy==0) || (tmpppy==19)){
  620.                                         kos_PutImage((RGB*)stone,24,24,4+tmpppx*24,tmpppy*24);
  621.                                 }
  622.                                 else
  623.                                 {
  624.                                         kos_PutImage((RGB*)skos,24,24,4+tmpppx*24,tmpppy*24);
  625.                                 }
  626.                         }
  627.                 }
  628.  
  629.            kos_WriteTextToWindow(40,40,0x80, 0xFFFFFF ,"Š®á¨«ª  ¤«ï Ž‘ Š®«¨¡à¨",22);
  630.            kos_WriteTextToWindow(40,60,0x80, 0xFFFFFF ,(char*)version,12);
  631.            kos_WriteTextToWindow(40,75,0x80, 0xFFFFFF ,"________________________________________",40);
  632.            
  633.            kos_WriteTextToWindow(40,120,0x80, 0xFFFFFF ,"Š®««¥ªâ¨¢ ࠧࠡ®â稪®¢:",18);
  634.            kos_WriteTextToWindow(40,150,0x80, 0xEEFFEE ,"€­¤à¥© Œ¨å ©«®¢¨ç aka Dron2004 - ¯à®£à ¬¬¨à®¢ ­¨¥, ¢áâ஥­­ ï £à ä¨ª  (¡¥§ ᪨­ )",32);
  635.            kos_WriteTextToWindow(40,170,0x80, 0xDDFFDD ,"Mario79 - â¥áâ¨à®¢ ­¨¥, ¯®¬®éì ¢ ࠧࠡ®âª¥, ¢ ¦­ë¥ ¨¤¥¨",35);
  636.            kos_WriteTextToWindow(40,190,0x80, 0xCCFFCC ,"Ataualpa - â¥áâ¨à®¢ ­¨¥, ¯®¬®éì ¢ ࠧࠡ®âª¥",36);
  637.            kos_WriteTextToWindow(40,210,0x80, 0xBBFFBB ,"Leency - â¥áâ¨à®¢ ­¨¥, ¯®¬®éì ¢ ࠧࠡ®âª¥, § ¬¥ç â¥«ì­ë¥ ᪨­ë, ¢ ¦­ë¥ ¨¤¥¨",62);
  638.            kos_WriteTextToWindow(40,230,0x80, 0xAAFFAA ,"Mike - â¥áâ¨à®¢ ­¨¥, ¯®¬®éì ¢ ࠧࠡ®âª¥",34);
  639.            kos_WriteTextToWindow(40,250,0x80, 0x99FF99 ,"bw - â¥áâ¨à®¢ ­¨¥, ¯®¬®éì ¢ ࠧࠡ®âª¥, ¢ ¦­ë¥ ¨¤¥¨",49);
  640.                         kos_WriteTextToWindow(40,270,0x80, 0x99FF99 ,"diamond - ¨¤¥ï ®â¬¥­ë 室 , â¥áâ¨à®¢ ­¨¥",49);
  641.  
  642.            kos_WriteTextToWindow(40,300,0x80, 0x88FF88 ,"Žâ¤¥«ì­®¥ ᯠᨡ®:",16);
  643.            kos_WriteTextToWindow(40,330,0x80, 0x77FF77 ,"‚ᥬ, ªâ® ¨£à ¥â ¢ íâã ¨£àã :-) !",50);
  644.  
  645.  
  646.            kos_WriteTextToWindow(40,430,0x80, 0x66FF66 ,"­ ¦¬¨â¥ <BACKSPACE> ¤«ï ¢®§¢à â  ¢ ¬¥­î",35);
  647.         }
  648.  
  649.  
  650.         if (status==4){
  651.                 kos_DrawBar(0,0,631,480,0x000000);     
  652.                
  653.  
  654.                 for (int tmpppy=0;tmpppy<20;tmpppy++){
  655.                         for (int tmpppx=0;tmpppx<26;tmpppx++){
  656.                                 if ((tmpppx==0) || (tmpppx==25) || (tmpppy==0) || (tmpppy==19)){
  657.                                         kos_PutImage((RGB*)stone,24,24,4+tmpppx*24,tmpppy*24);
  658.                                 }
  659.                                 else
  660.                                 {
  661.                                         kos_PutImage((RGB*)skos,24,24,4+tmpppx*24,tmpppy*24);
  662.                                 }
  663.                         }
  664.                 }
  665.  
  666.                 kos_WriteTextToWindow(215, 200,0x80, 0xFFFFFF ,"‚ë¡¥à¨â¥ ­ ¡®à ã஢­¥© (­ ¦¬¨â¥ <1> ¨«¨ <2>):",0);
  667.                 kos_WriteTextToWindow(215, 220,0x80, 0xFFFFFF ,"1. ‚áâ஥­­ë¥ ã஢­¨",0);
  668.                 kos_WriteTextToWindow(215, 240,0x80, 0xFFFFFF ,"2. ‚­¥è­¨© ­ ¡®à ã஢­¥©",0);
  669.  
  670.         }
  671.  
  672.        
  673.         kos_WindowRedrawStatus(2); //Êîíåö ïåðåðèñîâêè
  674.  
  675. }
  676.  
  677.  
  678.  
  679. //Îïèñàíèå óðîâíåé èãðû
  680. //, ãäå k - êîñèëêà
  681. //              g - òðàâà
  682. //              n - ñêîøåííàÿ òðàâà
  683. //              s - êàìåíü
  684. //              t - äåðåâî
  685. void initializeLevel(int levnum){
  686.         laststep=0;
  687.         if (external_levels==false){
  688.  
  689.         kosilkadirection=1;
  690.         if (levnum==1){
  691.                 static char tmparea[20][20]={{'k','t','g','g','g','g','g','s','g','g','g','g','g','g','g','g','g','g','g','g'},
  692.                                                                 {'g','s','g','s','g','g','g','s','g','s','g','g','s','g','g','g','g','g','g','g'},
  693.                                                                 {'g','t','g','s','g','g','g','s','g','s','g','g','s','g','g','g','g','g','g','g'},
  694.                                                                 {'g','s','g','s','g','g','g','s','g','s','g','g','s','g','g','g','g','g','g','g'},
  695.                                                                 {'g','t','g','s','g','g','g','s','g','s','g','g','s','g','g','g','g','g','g','g'},
  696.                                                                 {'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
  697.                                                                 {'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','s','s','s','g','g'},
  698.                                                                 {'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','s','s','s','g','g'},
  699.                                                                 {'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','s','s','s','g','g'},
  700.                                                                 {'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','s','g','g','g','g'},
  701.                                                                 {'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
  702.                                                                 {'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
  703.                                                                 {'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
  704.                                                                 {'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
  705.                                                                 {'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
  706.                                                                 {'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
  707.                                                                 {'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
  708.                                                                 {'g','s','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
  709.                                                                 {'g','t','g','s','g','g','g','s','g','g','g','g','s','g','g','g','g','g','g','g'},
  710.                                                                 {'g','g','g','s','g','g','g','g','g','s','g','g','s','g','g','g','g','g','g','g'}};
  711.                         for (int tyy=0;tyy<20;tyy++){
  712.                                 for (int txx=0;txx<20;txx++){
  713.                                
  714.                                         if (tmparea[txx][tyy]=='k'){
  715.                                                 kosilkax=tyy;
  716.                                                 kosilkay=txx;
  717.                                         }
  718.  
  719.                                         gamearea[txx][tyy]=tmparea[tyy][txx];
  720.                                 }
  721.                         }
  722.         }
  723.         if (levnum==2){
  724.                 static char tmparea[20][20]={{'s','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
  725.                                                                 {'s','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','s','g'},
  726.                                                                 {'g','k','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','s','g'},
  727.                                                                 {'g','g','g','g','g','g','g','g','g','g','g','g','s','s','g','g','g','g','g','g'},
  728.                                                                 {'g','g','g','g','g','g','g','g','g','g','g','g','s','s','g','g','g','g','g','g'},
  729.                                                                 {'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
  730.                                                                 {'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
  731.                                                                 {'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
  732.                                                                 {'s','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
  733.                                                                 {'s','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
  734.                                                                 {'g','g','g','g','g','g','g','g','s','s','g','g','g','g','g','g','g','s','s','g'},
  735.                                                                 {'g','g','g','g','g','g','g','g','s','s','g','g','g','g','g','g','g','s','s','g'},
  736.                                                                 {'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
  737.                                                                 {'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
  738.                                                                 {'g','g','g','g','g','g','g','g','g','g','g','g','g','s','s','g','g','g','g','g'},
  739.                                                                 {'g','g','g','g','g','g','g','g','g','g','g','g','g','s','s','g','g','g','g','g'},
  740.                                                                 {'g','g','g','s','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
  741.                                                                 {'g','g','g','s','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
  742.                                                                 {'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'},
  743.                                                                 {'g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g'}};
  744.                         for (int tyy=0;tyy<20;tyy++){
  745.                                 for (int txx=0;txx<20;txx++){
  746.                                
  747.                                         if (tmparea[txx][tyy]=='k'){
  748.                                                 kosilkax=tyy;
  749.                                                 kosilkay=txx;
  750.                                         }
  751.  
  752.                                         gamearea[txx][tyy]=tmparea[tyy][txx];
  753.                                 }
  754.                         }
  755.         }
  756.  
  757.         if (levnum==3){
  758.                 static char tmparea[20][20]={{'t','n','t','n','t','n','t','n','t','n','t','n','t','n','t','n','t','n','t','k'},
  759.                                                                 {'n','t','g','g','g','g','g','g','g','g','g','g','s','n','n','s','n','s','t','g'},
  760.                                                                 {'t','n','g','g','g','g','g','g','g','g','g','g','n','t','n','n','n','t','t','g'},
  761.                                                                 {'n','t','g','g','g','g','g','g','g','g','g','g','n','s','n','s','n','s','t','g'},
  762.                                                                 {'t','n','g','g','g','g','g','s','s','g','g','g','n','n','n','n','n','t','t','g'},
  763.                                                                 {'n','t','g','g','g','g','g','g','g','g','g','g','t','n','s','n','n','s','t','g'},
  764.                                                                 {'t','n','g','g','g','g','g','g','g','g','g','g','n','n','n','n','n','t','t','g'},
  765.                                                                 {'n','t','g','g','g','g','g','g','g','g','g','g','n','n','s','n','n','s','t','g'},
  766.                                                                 {'t','n','g','g','g','g','g','g','g','g','g','g','n','s','n','n','n','t','t','g'},
  767.                                                                 {'n','t','g','g','g','g','g','g','g','g','g','g','s','n','n','n','n','t','g','g'},
  768.                                                                 {'t','n','g','g','g','s','g','g','g','g','g','g','t','t','t','t','t','t','g','g'},
  769.                                                                 {'n','t','g','g','g','s','g','g','g','g','g','g','g','g','g','g','g','t','g','g'},
  770.                                                                 {'t','n','g','g','g','g','g','g','g','g','g','g','t','t','g','g','g','t','g','g'},
  771.                                                                 {'n','t','g','g','g','g','g','g','t','t','g','g','g','t','g','g','g','t','g','g'},
  772.                                                                 {'t','n','g','g','g','g','g','g','t','t','g','g','g','t','g','g','g','t','g','g'},
  773.                                                                 {'n','t','g','g','g','g','g','g','g','g','g','g','g','t','g','g','g','t','g','g'},
  774.                                                                 {'t','n','g','g','g','g','g','g','g','g','g','g','g','t','t','g','g','t','g','g'},
  775.                                                                 {'n','t','g','g','g','g','g','g','g','g','g','g','g','g','t','g','g','t','g','g'},
  776.                                                                 {'t','n','g','g','g','g','g','g','g','g','g','g','g','g','t','g','g','t','g','g'},
  777.                                                                 {'n','t','s','s','s','s','s','s','s','s','s','s','s','s','t','g','g','g','g','g'}};
  778.                         for (int tyy=0;tyy<20;tyy++){
  779.                                 for (int txx=0;txx<20;txx++){
  780.                                
  781.                                         if (tmparea[txx][tyy]=='k'){
  782.                                                 kosilkax=tyy;
  783.                                                 kosilkay=txx;
  784.                                         }
  785.  
  786.                                         gamearea[txx][tyy]=tmparea[tyy][txx];
  787.                                 }
  788.                         }
  789.         }
  790.  
  791.                 if (levnum==4){
  792.                 static char tmparea[20][20]={{'t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t'},
  793.                                                                 {'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','n','t'},
  794.                                                                 {'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','n','t'},
  795.                                                                 {'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','n','t'},
  796.                                                                 {'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','s','n','t'},
  797.                                                                 {'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','s','n','t'},
  798.                                                                 {'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','s','n','t'},
  799.                                                                 {'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','s','n','t'},
  800.                                                                 {'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','s','s','t'},
  801.                                                                 {'t','g','g','g','g','t','t','t','t','t','t','t','t','g','g','g','g','g','g','t'},
  802.                                                                 {'t','g','g','g','g','t','t','t','t','t','t','t','t','g','g','g','g','g','g','t'},
  803.                                                                 {'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','g','g','t'},
  804.                                                                 {'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','g','g','t'},
  805.                                                                 {'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','g','g','t'},
  806.                                                                 {'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','g','g','t'},
  807.                                                                 {'t','g','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','g','g','t'},
  808.                                                                 {'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
  809.                                                                 {'t','k','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
  810.                                                                 {'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
  811.                                                                 {'t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t'}};
  812.                         for (int tyy=0;tyy<20;tyy++){
  813.                                 for (int txx=0;txx<20;txx++){
  814.                                
  815.                                         if (tmparea[txx][tyy]=='k'){
  816.                                                 kosilkax=tyy;
  817.                                                 kosilkay=txx;
  818.                                         }
  819.  
  820.                                         gamearea[txx][tyy]=tmparea[tyy][txx];
  821.                                 }
  822.                         }
  823.         }
  824.  
  825.                         if (levnum==5){
  826.                 static char tmparea[20][20]={{'t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t'},
  827.                                                                 {'t','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
  828.                                                                 {'t','t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
  829.                                                                 {'t','s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
  830.                                                                 {'t','s','g','g','g','g','g','t','g','g','t','g','g','g','g','g','g','g','g','t'},
  831.                                                                 {'t','t','g','g','g','g','t','n','t','t','t','g','g','g','g','g','g','g','g','t'},
  832.                                                                 {'t','s','g','g','g','g','t','n','n','n','t','g','g','g','g','g','g','g','g','t'},
  833.                                                                 {'t','k','g','g','g','g','t','n','n','n','t','g','g','g','g','g','g','g','g','t'},
  834.                                                                 {'t','g','g','g','g','g','t','n','n','n','t','g','g','g','g','g','g','g','g','t'},
  835.                                                                 {'t','g','g','g','g','g','t','n','n','t','g','g','g','g','g','g','g','g','g','t'},
  836.                                                                 {'t','g','g','g','g','g','t','n','n','t','g','g','g','g','g','g','g','g','g','t'},
  837.                                                                 {'t','g','g','g','g','g','t','n','n','n','t','g','g','g','g','g','g','g','g','t'},
  838.                                                                 {'t','g','g','g','g','g','t','n','n','n','t','g','g','g','g','g','g','g','g','t'},
  839.                                                                 {'t','g','g','g','g','g','g','t','n','t','t','g','g','g','g','g','g','g','g','t'},
  840.                                                                 {'t','g','g','g','g','g','g','t','t','g','g','g','g','g','g','g','g','g','g','t'},
  841.                                                                 {'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
  842.                                                                 {'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
  843.                                                                 {'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
  844.                                                                 {'t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','t'},
  845.                                                                 {'t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t','t'}};
  846.                         for (int tyy=0;tyy<20;tyy++){
  847.                                 for (int txx=0;txx<20;txx++){
  848.                                
  849.                                         if (tmparea[txx][tyy]=='k'){
  850.                                                 kosilkax=tyy;
  851.                                                 kosilkay=txx;
  852.                                         }
  853.  
  854.                                         gamearea[txx][tyy]=tmparea[tyy][txx];
  855.                                 }
  856.                         }
  857.                         }
  858.  
  859.                 if (levnum==6){
  860.                 static char tmparea[20][20]={{'s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s'},
  861.                                                                 {'s','k','t','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
  862.                                                                 {'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
  863.                                                                 {'s','g','g','s','s','s','s','s','s','s','s','s','s','s','s','s','s','g','g','s'},
  864.                                                                 {'s','g','g','g','g','g','g','g','g','g','g','g','g','g','t','t','s','g','g','s'},
  865.                                                                 {'s','g','g','s','g','g','g','g','g','g','g','g','g','g','t','t','s','g','g','s'},
  866.                                                                 {'s','g','g','s','g','g','g','g','g','g','g','g','g','g','t','t','s','g','g','s'},
  867.                                                                 {'s','g','g','s','g','g','g','g','g','t','t','g','g','g','g','g','s','g','g','s'},
  868.                                                                 {'s','g','g','s','g','g','g','g','g','t','t','t','g','g','g','g','s','g','g','s'},
  869.                                                                 {'s','g','g','s','g','g','g','t','t','t','t','t','t','g','g','g','s','g','g','s'},
  870.                                                                 {'s','g','g','s','g','g','g','t','t','t','t','t','t','g','g','g','s','g','g','s'},
  871.                                                                 {'s','g','g','s','g','g','g','g','g','t','t','g','g','g','g','g','s','g','g','s'},
  872.                                                                 {'s','g','g','s','g','g','g','g','g','t','t','g','g','g','g','g','s','g','g','s'},
  873.                                                                 {'s','g','g','s','g','g','g','g','g','g','g','g','g','g','g','g','s','g','g','s'},
  874.                                                                 {'s','g','g','s','g','g','g','g','g','g','g','g','g','g','g','g','s','g','g','s'},
  875.                                                                 {'s','g','g','s','g','g','g','g','g','g','g','g','g','g','g','g','s','g','g','s'},
  876.                                                                 {'s','g','g','s','s','s','s','s','s','s','s','s','s','s','s','s','s','g','g','s'},
  877.                                                                 {'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
  878.                                                                 {'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
  879.                                                                 {'s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s'}};
  880.                         for (int tyy=0;tyy<20;tyy++){
  881.                                 for (int txx=0;txx<20;txx++){
  882.                                
  883.                                         if (tmparea[txx][tyy]=='k'){
  884.                                                 kosilkax=tyy;
  885.                                                 kosilkay=txx;
  886.                                         }
  887.  
  888.                                         gamearea[txx][tyy]=tmparea[tyy][txx];
  889.                                 }
  890.                         }
  891.                 }              
  892.  
  893.  
  894.                         if (levnum==7){
  895.                 static char tmparea[20][20]={{'s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s'},
  896.                                                                 {'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','t','t','s'},
  897.                                                                 {'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','t','t','s'},
  898.                                                                 {'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','t','t','s'},
  899.                                                                 {'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s','t','t','s'},
  900.                                                                 {'s','g','g','g','g','g','t','t','t','t','t','t','g','g','g','g','s','t','t','s'},
  901.                                                                 {'s','g','g','g','g','g','t','k','g','g','g','t','g','g','g','g','s','t','t','s'},
  902.                                                                 {'s','g','g','g','g','g','t','g','g','g','g','t','g','g','g','g','s','t','t','s'},
  903.                                                                 {'s','g','g','g','g','g','t','g','g','g','g','t','g','g','g','g','s','t','t','s'},
  904.                                                                 {'s','g','g','g','g','g','t','g','g','g','g','t','g','g','g','g','s','s','s','s'},
  905.                                                                 {'s','g','g','g','g','g','t','g','g','g','g','t','g','g','g','g','g','g','g','s'},
  906.                                                                 {'s','g','g','g','g','g','t','t','t','t','g','t','g','g','g','g','g','g','g','s'},
  907.                                                                 {'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
  908.                                                                 {'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
  909.                                                                 {'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
  910.                                                                 {'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
  911.                                                                 {'s','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','g','s'},
  912.                                                                 {'s','g','g','g','g','g','g','g','g','t','g','g','t','g','g','g','g','g','g','s'},
  913.                                                                 {'s','g','g','g','g','g','g','g','g','t','g','g','t','g','g','g','g','g','g','s'},
  914.                                                                 {'s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s','s'}};
  915.                         for (int tyy=0;tyy<20;tyy++){
  916.                                 for (int txx=0;txx<20;txx++){
  917.                                
  918.                                         if (tmparea[txx][tyy]=='k'){
  919.                                                 kosilkax=tyy;
  920.                                                 kosilkay=txx;
  921.                                         }
  922.  
  923.                                         gamearea[txx][tyy]=tmparea[tyy][txx];
  924.                                 }
  925.                         }
  926.                 }              
  927.                 }
  928.                 else
  929.                 {
  930.                         //ÂÍÅØÍÈÅ ÓÐÎÂÍÈ
  931.                         kosilkadirection=1;
  932.  
  933.                         int currentrow=0;
  934.                         int currentcol=0;
  935.  
  936.                         for (int tmpcntr=0;tmpcntr<400;tmpcntr++){
  937.                                
  938.                                 currentcol=(int)(tmpcntr/20);
  939.                                 currentrow=tmpcntr-(((int)(tmpcntr/20))*20);
  940.                                 switch(externallevels[tmpcntr+(400*(levnum-1))]){
  941.  
  942.                                 case 0:
  943.                                         gamearea[currentrow][currentcol]='n';
  944.                                         break;
  945.                                 case 1:
  946.                                         gamearea[currentrow][currentcol]='g';
  947.                                         break;
  948.                                 case 2:
  949.                                         gamearea[currentrow][currentcol]='k';
  950.                                         kosilkax=currentrow;
  951.                                         kosilkay=currentcol;
  952.                                         break;
  953.                                 case 3:
  954.                                         gamearea[currentrow][currentcol]='s';
  955.                                         break;
  956.                                 case 4:
  957.                                         gamearea[currentrow][currentcol]='t';
  958.                                         break;
  959.  
  960.                                 }
  961.                         }
  962.                        
  963.  
  964.                 }
  965.  
  966.         draw_window();
  967.  
  968. }
  969.  
  970. //Ïðåîâåðÿåì îñòàòîê òðàâû
  971. int grassLeft(){
  972.         int leftgrass=0;
  973.         for (int chky=0;chky<20;chky++){
  974.                 for (int chkx=0;chkx<20;chkx++){
  975.                         if (gamearea[chkx][chky]=='g') {
  976.                                 leftgrass++;
  977.                         }
  978.                 }
  979.         }
  980.         return leftgrass;
  981. }
  982.  
  983.  
  984. //Ìåíÿåì óðîâåíü èëè âûâîäèì ñîîáùåíèå î òîì, ÷òî âñå óðîâíè ïðîéäåíû
  985. void updateStatus(){
  986.  
  987.        
  988.         if (grassLeft()==0) {
  989.                 if (level==levelcount){
  990.                         gamestarted=false;
  991.                         status=2;
  992.                         draw_window();
  993.                 } else {
  994.                         gamestarted=false;
  995.                         interlevelpause();
  996.                         level++;
  997.                         initializeLevel(level);
  998.                         gamestarted=true;
  999.                 }
  1000.         }
  1001.        
  1002. }
  1003.  
  1004.  
  1005.  
  1006.  
  1007. void decode_skin(){
  1008.         int currentbyte3x=0;
  1009.         RGB tmpRGB;
  1010.         int tmpcc1=0;
  1011.  
  1012.         for (tmpcc1=0;tmpcc1<576;tmpcc1++){
  1013.  
  1014.                 tmpRGB.r= skindata[currentbyte3x];
  1015.                 tmpRGB.g= skindata[currentbyte3x+1];
  1016.                 tmpRGB.b= skindata[currentbyte3x+2];
  1017.                 kosilka_d[tmpcc1]=tmpRGB;      
  1018.                 currentbyte3x+=3;
  1019.         }
  1020.  
  1021.         for (tmpcc1=0;tmpcc1<576;tmpcc1++){
  1022.  
  1023.                 tmpRGB.r= skindata[currentbyte3x];
  1024.                 tmpRGB.g= skindata[currentbyte3x+1];
  1025.                 tmpRGB.b= skindata[currentbyte3x+2];
  1026.                 kosilka_u[tmpcc1]=tmpRGB;      
  1027.                 currentbyte3x+=3;
  1028.         }
  1029.  
  1030.         for (tmpcc1=0;tmpcc1<576;tmpcc1++){
  1031.  
  1032.                 tmpRGB.r= skindata[currentbyte3x];
  1033.                 tmpRGB.g= skindata[currentbyte3x+1];
  1034.                 tmpRGB.b= skindata[currentbyte3x+2];
  1035.                 kosilka_l[tmpcc1]=tmpRGB;      
  1036.                 currentbyte3x+=3;
  1037.         }
  1038.  
  1039.         for (tmpcc1=0;tmpcc1<576;tmpcc1++){
  1040.  
  1041.                 tmpRGB.r= skindata[currentbyte3x];
  1042.                 tmpRGB.g= skindata[currentbyte3x+1];
  1043.                 tmpRGB.b= skindata[currentbyte3x+2];
  1044.                 kosilka_r[tmpcc1]=tmpRGB;      
  1045.                 currentbyte3x+=3;
  1046.         }
  1047.  
  1048.         for (tmpcc1=0;tmpcc1<576;tmpcc1++){
  1049.  
  1050.                 tmpRGB.r= skindata[currentbyte3x];
  1051.                 tmpRGB.g= skindata[currentbyte3x+1];
  1052.                 tmpRGB.b= skindata[currentbyte3x+2];
  1053.                 skos[tmpcc1]=tmpRGB;   
  1054.                 currentbyte3x+=3;
  1055.         }
  1056.  
  1057.         for (tmpcc1=0;tmpcc1<576;tmpcc1++){
  1058.  
  1059.                 tmpRGB.r= skindata[currentbyte3x];
  1060.                 tmpRGB.g= skindata[currentbyte3x+1];
  1061.                 tmpRGB.b= skindata[currentbyte3x+2];
  1062.                 grass[tmpcc1]=tmpRGB;  
  1063.                 currentbyte3x+=3;
  1064.         }
  1065.  
  1066.         for (tmpcc1=0;tmpcc1<576;tmpcc1++){
  1067.  
  1068.                 tmpRGB.r= skindata[currentbyte3x];
  1069.                 tmpRGB.g= skindata[currentbyte3x+1];
  1070.                 tmpRGB.b= skindata[currentbyte3x+2];
  1071.                 stone[tmpcc1]=tmpRGB;  
  1072.                 currentbyte3x+=3;
  1073.         }
  1074.  
  1075.         for (tmpcc1=0;tmpcc1<576;tmpcc1++){
  1076.  
  1077.                 tmpRGB.r= skindata[currentbyte3x];
  1078.                 tmpRGB.g= skindata[currentbyte3x+1];
  1079.                 tmpRGB.b= skindata[currentbyte3x+2];
  1080.                 tree[tmpcc1]=tmpRGB;   
  1081.                 currentbyte3x+=3;
  1082.         }
  1083.  
  1084. }
  1085.  
  1086.  
  1087.  
  1088. void load_external_levels(){
  1089.  
  1090.         CKosFile lev(getLevelsPathName());
  1091.  
  1092. level_read_result=lev.Read (external_levels_count,1);
  1093.  
  1094.                 if (level_read_result == 1){
  1095.                                 external_levels_available=true;
  1096.                 }
  1097.                 else
  1098.                 {
  1099.                                 external_levels_available=false;
  1100.                 };
  1101.  
  1102.  
  1103.                 if (external_levels_count[0]==0){
  1104.                         external_levels_available=false;
  1105.                 }
  1106.                 else
  1107.                 {
  1108.                         externallevels = new Byte[400*external_levels_count[0]];
  1109.                         lev.Read (externallevels,400*external_levels_count[0]);
  1110.                 }
  1111.  
  1112.                
  1113.  
  1114. }
  1115.  
  1116. void app_halt(){
  1117.  
  1118.         delete apppath;
  1119.         delete levpath;
  1120.         if (external_levels_available==true) {delete externallevels;}
  1121.         kos_ExitApp();
  1122.  
  1123. }
  1124.  
  1125. void kos_Main(){
  1126.  
  1127.        
  1128.         load_external_levels();
  1129.  
  1130.         CKosFile  skin(getSkinPathName());
  1131.        
  1132.                 read_result=skin.Read (skindata,13824);
  1133.                 if (read_result != 13824){
  1134.                         skin_available=false;
  1135.                 }
  1136.                 else
  1137.                 {
  1138.                         skin_available=true;
  1139.                 };
  1140.  
  1141.                 if (skin_available==false){
  1142.                         decode_graphics(kosilka_d1,kosilka_d);
  1143.                         decode_graphics(kosilka_u1,kosilka_u);
  1144.                         decode_graphics(kosilka_l1,kosilka_l);
  1145.                         decode_graphics(kosilka_r1,kosilka_r);
  1146.                         decode_graphics(skos1,skos);
  1147.                         decode_graphics(stone1,stone);
  1148.                         decode_graphics(tree1,tree);
  1149.                         decode_graphics(grass1,grass);
  1150.                         skinned=false;
  1151.                 }
  1152.                 else
  1153.                 {
  1154.                         decode_skin();
  1155.                         skinned=true;
  1156.                 }
  1157.  
  1158.         draw_window();
  1159.  
  1160.         for (;;){
  1161.  
  1162.                 switch (kos_WaitForEvent()){
  1163.                 case 1:
  1164.                         w_redraw=true;
  1165.                         draw_window();
  1166.                         break;
  1167.                 case 2:
  1168.                         Byte keyCode;
  1169.                         kos_GetKey(keyCode);
  1170.                         if (status==1){
  1171.                         if (gamestarted==true){
  1172.                                 switch (keyCode){
  1173.                                 case 177:
  1174.                                         if (kosilkay<19){
  1175.                                                 if (gamearea[kosilkax][kosilkay+1]=='g'){
  1176.                                                         gamearea[kosilkax][kosilkay]='n';
  1177.                                                         gamearea[kosilkax][kosilkay+1]='k';
  1178.                                                        
  1179.                                                         if (drawanimation==true) {animate(kosilkax,kosilkay,1);}
  1180.  
  1181.  
  1182.                                                         lastkosilkadirection=kosilkadirection;
  1183.                                                         laststep=1;
  1184.  
  1185.                                                         kosilkay++;
  1186.                                                         kosilkadirection=1;
  1187.                                                         draw_element(kosilkax,kosilkay);
  1188.                                                         draw_element(kosilkax,kosilkay-1);
  1189.                                                         display_grass_left();
  1190.                                                         updateStatus();
  1191.                                                 }
  1192.                                         }
  1193.                                         break;
  1194.                                 case 178:
  1195.                                         if (kosilkay>0){
  1196.                                                 if (gamearea[kosilkax][kosilkay-1]=='g'){
  1197.                                                         gamearea[kosilkax][kosilkay]='n';
  1198.                                                         gamearea[kosilkax][kosilkay-1]='k';
  1199.  
  1200.                                                         if (drawanimation==true) {animate(kosilkax,kosilkay,2);}
  1201.  
  1202.                                                         lastkosilkadirection=kosilkadirection;
  1203.                                                         laststep=2;
  1204.  
  1205.                                                         kosilkay--;
  1206.                                                         kosilkadirection=2;
  1207.                                        
  1208.                                                         draw_element(kosilkax,kosilkay);
  1209.                                                         draw_element(kosilkax,kosilkay+1);
  1210.                                                         display_grass_left();
  1211.                                                         updateStatus();
  1212.                                                 }
  1213.                                         }
  1214.                                         break; 
  1215.        
  1216.                                 case 179:
  1217.                                         if (kosilkax<19){
  1218.                                                 if (gamearea[kosilkax+1][kosilkay]=='g'){
  1219.                                                         gamearea[kosilkax][kosilkay]='n';
  1220.                                                         gamearea[kosilkax+1][kosilkay]='k';
  1221.  
  1222.                                                         if (drawanimation==true) {animate(kosilkax,kosilkay,3);}
  1223.  
  1224.  
  1225.                                                         lastkosilkadirection=kosilkadirection;
  1226.                                                         laststep=3;
  1227.  
  1228.                                                         kosilkax++;
  1229.                                                         kosilkadirection=4;
  1230.  
  1231.                                                         draw_element(kosilkax,kosilkay);
  1232.                                                         draw_element(kosilkax-1,kosilkay);
  1233.                                                         display_grass_left();
  1234.                                                         updateStatus();
  1235.                                                 }
  1236.                                         }
  1237.                                         break;
  1238.                        
  1239.                                 case 176:
  1240.                                         if (kosilkax>0){
  1241.                                                 if (gamearea[kosilkax-1][kosilkay]=='g'){
  1242.                                                         gamearea[kosilkax][kosilkay]='n';
  1243.                                                         gamearea[kosilkax-1][kosilkay]='k';
  1244.  
  1245.                                                         if (drawanimation==true) {animate(kosilkax,kosilkay,4);}
  1246.  
  1247.                                                         lastkosilkadirection=kosilkadirection;
  1248.                                                         laststep=4;
  1249.  
  1250.                                                         kosilkax--;
  1251.                                                         kosilkadirection=3;
  1252.  
  1253.                                                         draw_element(kosilkax,kosilkay);
  1254.                                                         draw_element(kosilkax+1,kosilkay);
  1255.                                                         display_grass_left();
  1256.                                                         updateStatus();
  1257.                                                 }
  1258.                                         }
  1259.                                         break;
  1260.  
  1261.                                 case 27:
  1262.                                         if (lives>0){
  1263.                                                 lives--;
  1264.                                                 initializeLevel(level);
  1265.  
  1266.                                         } else {
  1267.                                                 gamestarted=false;
  1268.                                                 status=3;
  1269.                                                 draw_window();
  1270.                                         }
  1271.                                         break;
  1272.  
  1273.                                 case 8:
  1274.                                         if (laststep!=0){
  1275.                                                 kosilkadirection=lastkosilkadirection;
  1276.                                                 if (laststep==1){
  1277.                                                         gamearea[kosilkax][kosilkay]='g';
  1278.                                                         gamearea[kosilkax][kosilkay-1]='k';
  1279.                                                         draw_element(kosilkax,kosilkay);
  1280.                                                         draw_element(kosilkax,kosilkay-1);
  1281.                                                         kosilkay--;
  1282.                                                 }
  1283.                                         if (laststep==2){
  1284.                                                         gamearea[kosilkax][kosilkay]='g';
  1285.                                                         gamearea[kosilkax][kosilkay+1]='k';
  1286.                                                         draw_element(kosilkax,kosilkay);
  1287.                                                         draw_element(kosilkax,kosilkay+1);
  1288.                                                         kosilkay++;
  1289.                                                 }
  1290.  
  1291.                                         if (laststep==3){
  1292.                                                         gamearea[kosilkax][kosilkay]='g';
  1293.                                                         gamearea[kosilkax-1][kosilkay]='k';
  1294.                                                         draw_element(kosilkax,kosilkay);
  1295.                                                         draw_element(kosilkax-1,kosilkay);
  1296.                                                         kosilkax--;
  1297.                                                 }
  1298.  
  1299.                                         if (laststep==4){
  1300.                                                         gamearea[kosilkax][kosilkay]='g';
  1301.                                                         gamearea[kosilkax+1][kosilkay]='k';
  1302.                                                         draw_element(kosilkax,kosilkay);
  1303.                                                         draw_element(kosilkax+1,kosilkay);
  1304.                                                         kosilkax++;
  1305.                                                 }
  1306.  
  1307.  
  1308.                                                 laststep=0;
  1309.                                         }
  1310.                                         break;
  1311.                
  1312.                                 }
  1313.  
  1314.                         }
  1315.                         }
  1316.                         if (status==0){
  1317.                                 if (keyCode==13){ //enter
  1318.                                         if (external_levels_available==true){
  1319.                                                 status=4;
  1320.                                                 draw_window();
  1321.                                         }
  1322.                                         else
  1323.                                         {
  1324.                                                 status=1;
  1325.                                                 initializeLevel(1);
  1326.                                                 gamestarted=true;
  1327.                                         }
  1328.                                                                        
  1329.                                 }
  1330.  
  1331.                                 if (keyCode==103){
  1332.                                         if (drawgraphics==true){
  1333.                                                 drawgraphics=false;
  1334.                                         } else {
  1335.                                                 drawgraphics=true;
  1336.                                         }
  1337.                                        
  1338.                                         if (drawgraphics==true){
  1339.                                                 kos_PutImage((RGB*)kosilka_d,24,24,305,150);
  1340.                                         }
  1341.                                         else
  1342.                                         {
  1343.                                         kos_DrawBar(305,150,24,24,0x00AAAA);
  1344.                                         }
  1345.                                 }
  1346.                                
  1347.                                 if (keyCode==97){
  1348.                                         if (drawanimation==true){
  1349.                                                 drawanimation=false;
  1350.                                         } else {
  1351.                                                 drawanimation=true;
  1352.                                         }
  1353.                                        
  1354.                                         if (drawanimation==true){
  1355.                                                 kos_DrawBar(335,150,24,24,0x00AA00);
  1356.                                         }
  1357.                                         else
  1358.                                         {
  1359.                                                 kos_DrawBar(335,150,24,24,0xAA0000);
  1360.                                         }
  1361.                                 }
  1362.                                 if (keyCode==104){
  1363.                                                 status=-1;
  1364.                                                 draw_window();
  1365.                                 }
  1366.  
  1367.                                 if (keyCode==115){
  1368.                                
  1369.                                         if (skin_available==true){
  1370.                                         if (skinned==true){
  1371.                                                 skinned=false;
  1372.                                                 decode_graphics(kosilka_d1,kosilka_d);
  1373.                                                 decode_graphics(kosilka_u1,kosilka_u);
  1374.                                                 decode_graphics(kosilka_l1,kosilka_l);
  1375.                                                 decode_graphics(kosilka_r1,kosilka_r);
  1376.                                                 decode_graphics(skos1,skos);
  1377.                                                 decode_graphics(stone1,stone);
  1378.                                                 decode_graphics(tree1,tree);
  1379.                                                 decode_graphics(grass1,grass);
  1380.                                         } else {
  1381.                                                 skinned=true;
  1382.                                                 decode_skin();
  1383.                                         }
  1384.  
  1385.                                         draw_window();
  1386.  
  1387.                                         }
  1388.  
  1389.                                 }
  1390.                                 if (keyCode==27){
  1391.                                         app_halt();
  1392.                                 }
  1393.                                
  1394.                         }
  1395.  
  1396.                         if (status==4){
  1397.                                 if (keyCode==49){ //1
  1398.                                                 external_levels=false;
  1399.                                                 status=1;
  1400.                                                 initializeLevel(1);
  1401.                                                 gamestarted=true;
  1402.                                                                        
  1403.                                 }
  1404.                                
  1405.                                 if (keyCode==50){ //2
  1406.                                                 external_levels=true;
  1407.                                                 levelcount=external_levels_count[0];
  1408.                                                 status=1;
  1409.                                                 initializeLevel(1);
  1410.                                                 gamestarted=true;
  1411.                                                                        
  1412.                                 }
  1413.                         }
  1414.  
  1415.                         if (status==2){
  1416.                                 if (keyCode==113){
  1417.                                                 lives=2;
  1418.                                                 status=0;
  1419.                                                 level=1;
  1420.                                                 draw_window();
  1421.                                                 gamestarted=true;
  1422.                                 }
  1423.                         }
  1424.                        
  1425.                         if (status==3){
  1426.                                 if (keyCode==113){
  1427.                                                 lives=2;
  1428.                                                 status=0;
  1429.                                                 level=1;
  1430.                                                 draw_window();
  1431.                                                 gamestarted=true;      
  1432.  
  1433.                                 }
  1434.                                 if (keyCode==114){
  1435.                                                 lives=2;
  1436.                                                 status=1;
  1437.                                                 level=1;
  1438.                                                 initializeLevel(1);
  1439.                                                 gamestarted=true;
  1440.                                 }
  1441.  
  1442.                         }
  1443.  
  1444.                         if (status==-1){
  1445.                                 if (keyCode==8){
  1446.                                         status=0;
  1447.                                         draw_window();
  1448.                                 }
  1449.                         }
  1450.  
  1451.                         //Âûâîäèì êîä íàæàòîé êëàâèøè. Ôè÷à âðåìåííàÿ
  1452.         /*              kos_DrawBar(20,250,150,10,0xEEEEEE);
  1453.                         kos_WriteTextToWindow(20,250,0x80, 0 ,"Button",0);
  1454.                         kos_DisplayNumberToWindow(keyCode,3,70,250,0x0000FF,nbDecimal,false);  */
  1455.                         break;
  1456.                 case 3:
  1457.                        
  1458.                         app_halt();
  1459.                         break;
  1460.                 }
  1461.         }
  1462. }
  1463.  
  1464. // Êîíåö èñõîäíèêà ;-)
  1465.